1.模態modal
A介面
<Modal animationType='slide' transparent={false} visible={this.state.isModal} onRequestClose={() => this.onRequestClose()}> <HalfHourHot removeModal={(data) => this.closeModal(data)}/></Modal> constructor(props) { super(props); this.state = { isModal: false, }; }; onRequestClose() { this.setState({ isModal: false, }); }; closeModal(data) { this.setState({ isModal: data, }); };
HalfHourHot介面必須有一個removeModal屬性,且是func
static propTypes = { removeModal: PropTypes.func, }; //某處操作需要返回到A介面 popToHome(data) { //this.props.navigator.pop(); this.props.removeModal(data); }
2.AsyncStorage—SharedPreferences
http://www.cnblogs.com/huangjialin/p/6245122.html 3.DeviceEventEmitter—發送通知
A介面
componentDidMount() { this.listener = DeviceEventEmitter.addListener('listen', (value) => { console.log(value.num); }); }; componentWillUnmount() { this.listener.remove('listen'); };
B介面發送
DeviceEventEmitter.emit('listen', {num: 12});