From f5b24e4376d878983970fa7b2d319a159ddf9caf Mon Sep 17 00:00:00 2001 From: Gajanan Bodhankar <124874678+GajananBodhankar@users.noreply.github.com> Date: Fri, 21 Feb 2025 22:42:40 +0530 Subject: [PATCH] Update screen-options.md by detailing navigation.setOptions() --- versioned_docs/version-7.x/screen-options.md | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/versioned_docs/version-7.x/screen-options.md b/versioned_docs/version-7.x/screen-options.md index 1f95d0f348..f3da9ea860 100644 --- a/versioned_docs/version-7.x/screen-options.md +++ b/versioned_docs/version-7.x/screen-options.md @@ -502,3 +502,27 @@ The `navigation` object has a `setOptions` method that lets you update the optio Update options ``` + +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: , // Custom component on the left + headerTitle: , // Custom title component + headerRight: , // Custom component on the right + }); + }, [navigation, props]); // Adding 'props' as a dependency if required + + return ( + // Your screen content + + My Screen Content + + ); +}; +```