0

how can I render headerRight in React navigation? I have tried everything that is told in this tutorial: https://reactnavigation.org/docs/header-buttons/

Still not working/rendering on the screen.


const HomeStack = createNativeStackNavigator();
const AuthStack = createNativeStackNavigator();

    <NavigationContainer>
      {isSignedIn ? (
        <Provider store={store}>
          <HomeStack.Navigator
            screenOptions={{
              header: (props) => <CustomNavigationBar {...props} />,
            }}
          >
            <HomeStack.Screen
              name="HomeTabs"
              component={BottomTabs}
              options={({ route }) => ({
                headerTitle: getHeaderTitle(route),
              })}
            ></HomeStack.Screen>
            <HomeStack.Screen
              name={screenRoutes.ADD_EVENT}
              component={Event}
              options={{ headerTitle: "Add event" }}
            ></HomeStack.Screen>
            <HomeStack.Screen
              name={screenRoutes.UPDATE_EVENT}
              component={Event}
              options={{
                headerTitle: "Update event",

//This: 
                headerRight: () => <IconButton icon={"camera"}/>


              }}
            ></HomeStack.Screen>
          </HomeStack.Navigator>
        </Provider>
      ) : (
        <AuthStack.Navigator>
          <AuthStack.Screen name={screenRoutes.SIGN_IN} component={SignIn} />
          <AuthStack.Screen name={screenRoutes.SIGN_UP} component={SignUp} />
        </AuthStack.Navigator>
      )}
    </NavigationContainer>
  );
}
2
  • 2
    headerRight (like most of the other header options) only works when you're using the stock header. When you make a custom one you'll have to pass the icon to it yourself. Commented Sep 23, 2023 at 20:48
  • @Abe Aah true... What a stupid mistake, thanks a lot! Commented Sep 24, 2023 at 6:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.