Could you give us a little bit more details ? Are you using a navigator like react-navigation ?
If you want to trigger a method of the parent component from a child component, you should use props.
So, you can do something like this, if you are managing your view by yourself:
export default class Wrapper extends Component
{
state = {screen: 'Home'}
useNewScreen = screenToUse => this.setState({screen: screenToUse})
reloadHome = () => yourFunctionToRefreshThePage
render = () =>
{
if (this.state.screen === 'Home')
return (<Home goToNotif={() => this.useNewScreen('Notif')} />);
else if (this.state.screen === 'Notif')
return (<Notif onGoBack={() => this.reloadHome()} />);
}
}
class Home extends Component
{
render = () =>
{
return (
<TouchableOpacity onPress={() => this.props.goToNotif()}/>
);
}
}
class Notif extends Component
{
render = () =>
{
return (
<TouchableOpacity onPress={() => this.props.onGoBack()}/>
);
}
}
If you are using react-navigation, you can use the same idea:
You navigate to the new page with a special props
this.props.navigation.navigate('Notif', {
onGoBack: () => this.refresh()
});
And when you want to go back, you can call this method
this.props.navigation.state.params.onGoBack();
this.props.navigation.goBack(null);
I hope this is clear enough :)