怎么在react-navigatiaon主View上添加Toast
来源:5-13 Popular(最热)模块的离线缓存功能实现
tomatoCoder
2017-05-27
老师您好!我想请问一下,我现在想把Toast加到主View上,老师的方法是这样的:
export default class First extends Component {
render() {
return(
<View style={styles.container}>
<TabNavigator>
{this._renderTab(PopularPage,'tb_popular','最热',require('../../res/images/ic_polular.png'))}
{this._renderTab(TrendingPage,'tb_trending','趋势',require('../../res/images/ic_trending.png'))}
{this._renderTab(FavoritePage,'tb_favorite','收藏',require('../../res/images/ic_favorite.png'))}
{this._renderTab(MyPage,'tb_my','我的',require('../../res/images/ic_my.png'))}
</TabNavigator>
<Toast ref={(toast)=>this.toast=toast}/> //添加Toast
</View>
);
}
}
但用react-navigatiaon 里的方法是这样的:
const FirstApp = TabNavigator({
Popular: {screen: homePage},
Trending: {screen: TrendPage},
Favorite:{ screen: FavoritePage},
Mine:{screen:MinePage}
});
问题是<Toast ref={(toast)=>this.toast=toast}/>应该放到哪里?求指导一下
1回答
-
CrazyCodeBoy
2017-05-31
放在组件的跟布局下即可,如果你觉得放在FirstApp 中不方便也可以放在Popular等组件中,可参考https://github.com/crazycodeboy/react-native-easy-toast
00
相似问题