I’m not totally following — could you share some code?
Spencer Carli
1

/*
----------> app/router.js
*/
export const
FeedStack = StackNavigator({
Feed: {
screen: Feed, /*cf la barre en haut*/
navigationOptions: {
tabBar: {
label: 'Feed',
icon: ({ tintColor }) => <Icon name="list" size={35} color={tintColor} />
},
},
},
Detail: {
screen: Detail,
navigationOptions: {
title: ({ state }) => `${ state.params.content }`
},
},
});
/*
---------> app/feed.js
*/
onDetail = (data) => {
this.props.navigation.navigate('Detail', { ...data });
};
render() {
return (
<View >
<ScrollView>
<List containerStyle={{ marginBottom: 40 }}>
{this.props.data.map((data) => {
return(
<View key={data._id}>
<Element key={data._id} test={data.test} />
<Text onPress={() => this.onDetail(data)}>
Link Detail
</Text>
</View>
);
})}
</List>
</ScrollView>
</View>
);
}

I can use this.props.navigation in feed.js (because it is referenced in the StackNavigator in router.js I guess)

BUT if I wanna use it in the Element class for example I cannot reach it. That’s what I meant with child component.

I tried to declare Element in the StackNavigatorand other workarounds without success :(

Show your support

Clapping shows how much you appreciated Ben’s story.