Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reactnaviataion change title

import * as React from 'react';
import { View, Text, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

function HomeScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
      <Button
        title="Go to Profile"
        onPress={() =>
          navigation.navigate('Profile', { name: 'Custom profile header' })
        }
      />
    </View>
  );
}

function ProfileScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Profile screen</Text>
      <Button title="Go back" onPress={() => navigation.goBack()} />
    </View>
  );
}

const Stack = createStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
          name="Home"
          component={HomeScreen}
          options={{ title: 'My home' }}
        />
        <Stack.Screen
          name="Profile"
          component={ProfileScreen}
          options={({ route }) => ({ title: route.params.name })}
        />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;
Comment

React and React-Native Navigation Replace Title With Component

function LogoTitle() {
  return (
    <Image
      style={{ width: 50, height: 50 }}
      source={require('@expo/snack-static/react-native-logo.png')}
    />
  );
}

function StackScreen() {
  return (
    <Stack.Navigator>
      <Stack.Screen
        name="Home"
        component={HomeScreen}
        options={{ headerTitle: (props) => <LogoTitle {...props} /> }}
      />
    </Stack.Navigator>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodemon 
Javascript :: javascript non primitive data types 
Javascript :: python run javascript 
Javascript :: get selected option from select javascript 
Javascript :: react useeffect hook 
Javascript :: back press subscriptions i is not a function react native 
Javascript :: React: readmore and read less 
Javascript :: Sum of Polygon Angles in javascript 
Javascript :: react text docoration none 
Javascript :: what is useref in react 
Javascript :: javascript object array sum of values in object 
Javascript :: return then javascript 
Javascript :: add image inside a div on specific position javascript 
Javascript :: Reactjs exemple class component 
Javascript :: javascript read file 
Javascript :: ffmpeg thumbnail generator SIZE 
Javascript :: lodash group by except group null items 
Javascript :: The loading of x in a frame is denied by “X-Frame-Options“ directive set to “SAMEORIGIN“ js 
Javascript :: Which condition will print hello? var a=2; var b=3; if(a___?___b){console.log(“Hello”);} 
Javascript :: asynchronous in javascript 
Javascript :: nodejs ERR_CONNECTION_REFUSED 
Javascript :: node start is too slow windows 10 
Javascript :: p5js no stroke 
Javascript :: js two array combining with id neasted 
Javascript :: empty string in javascript 
Javascript :: javascript set() handler 
Javascript :: javascript string insensitive compare 
Javascript :: How to make a JSON call to an URL 
Javascript :: js after settimeout 
Javascript :: Invalid prettier configuration file detected. See log for details. 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =