Answers for "access initialparams react native functional component"

0

access initialparams react native functional component

You can pass it as the initial param like below

  <Stack.Screen
    name="Home"
    component={HomeScreen}
    initialParams={{ setState: setState }}
  />
And access it like below

function HomeScreen({ navigation, route }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Button
        title="setState"
        onPress={() => route.params.setState(false)}
      />
    </View>
  );
}
Posted by: Guest on September-27-2021

Code answers related to "access initialparams react native functional component"

Code answers related to "Javascript"

Browse Popular Code Answers by Language