Skip to content

Commit e2813c6

Browse files
Update screen-options.md with more detailing about navigation.setOptions()
1 parent db23292 commit e2813c6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

versioned_docs/version-7.x/screen-options.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,26 @@ The `navigation` object has a `setOptions` method that lets you update the optio
502502
Update options
503503
</Button>
504504
```
505+
Futhermore, `navigation.setOptions()` can be used to set Custom header components for `headerLeft`, `headerTitle` and `headerRight`
506+
507+
```js name="setOptions for navigation" snack dependencies=@expo/vector-icons
508+
import React, { useEffect } from 'react';
509+
510+
const MyScreen = ({ navigation, route, ...props }) => {
511+
useEffect(() => {
512+
// Setting custom header components
513+
navigation.setOptions({
514+
headerLeft: <CustomHeaderLeftComponent {...props} />, // Custom component on the left
515+
headerTitle: <CustomHeaderTitleComponent {...props} />, // Custom title component
516+
headerRight: <CustomHeaderRightComponent {...props} />, // Custom component on the right
517+
});
518+
}, [navigation, props]); // Adding 'props' as a dependency if required
519+
520+
return (
521+
// Your screen content
522+
<View>
523+
<Text>My Screen Content</Text>
524+
</View>
525+
);
526+
};
527+
```

0 commit comments

Comments
 (0)