这是我的反应原生代码: NavigatorIOSref='nav'style={styles.container}initialRoute={{ title: 'List', component: TaskList, rightButtonTitle: 'new', onRightButtonPress: () = { this.refs.nav.push({ title: 'Add Task', component: AddTas
<NavigatorIOS ref='nav' style={styles.container} initialRoute={{ title: 'List', component: TaskList, rightButtonTitle: 'new', onRightButtonPress: () => { this.refs.nav.push({ title: 'Add Task', component: AddTask }); } }} />
如何将一些通知从AddTask组件推送到TaskList组件?
文档说:“对于没有父子关系的两个组件之间的通信,您可以设置自己的全局事件系统.”
所以我需要建立一个全球事件系统?
像 communicate-between-components说:For communication between two components that don’t have a
parent-child relationship, 07001 pattern is one of the possible
ways to arrange this.
您可以在react-native项目中使用Flux.
这是Flux React-Native的演示:
您可以查看github的源代码.