access initialparams react native functional component

Solutions on MaxInterview for access initialparams react native functional component by the best coders in the world

showing results for - "access initialparams react native functional component"
Rania
21 Nov 2018
1You can pass it as the initial param like below
2
3  <Stack.Screen
4    name="Home"
5    component={HomeScreen}
6    initialParams={{ setState: setState }}
7  />
8And access it like below
9
10function HomeScreen({ navigation, route }) {
11  return (
12    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
13      <Button
14        title="setState"
15        onPress={() => route.params.setState(false)}
16      />
17    </View>
18  );
19}