Skip to content

Update screen-options.md with more detailing about navigation.setOpti… #1406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions versioned_docs/version-7.x/screen-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,26 @@ The `navigation` object has a `setOptions` method that lets you update the optio
Update options
</Button>
```
Futhermore, `navigation.setOptions()` can be used to set Custom header components for `headerLeft`, `headerTitle` and `headerRight`

```js name="setOptions for navigation" snack dependencies=@expo/vector-icons
import React, { useEffect } from 'react';

const MyScreen = ({ navigation, route, ...props }) => {
useEffect(() => {
// Setting custom header components
navigation.setOptions({
headerLeft: <CustomHeaderLeftComponent {...props} />, // Custom component on the left
headerTitle: <CustomHeaderTitleComponent {...props} />, // Custom title component
headerRight: <CustomHeaderRightComponent {...props} />, // Custom component on the right
});
}, [navigation, props]); // Adding 'props' as a dependency if required

return (
// Your screen content
<View>
<Text>My Screen Content</Text>
</View>
);
};
```
Loading