1
私の状態をレンダリング機能から変更しようとしていますが、動作しません。リアクションネイティブsetState
render() {
return (
<View>
// some code
{this._renderModal()}
</View>
)
}
_renderModal() {
let channel = this.props.pusher.subscribe('my-channel');
channel.bind('my-event', data => {
this.setState({
requestedToEnter: false
});
this.props.navigation.getNavigator('root').push(Router.getRoute('order', { restaurant_id }));
});
return (
<Modal
animationType={'slide'}
transparent={false}
visible={this.state.requestedToEnter}
onRequestClose={this._handleEnter}>
// some components
</Modal>
)
}
私はそれにバインドされた機能を起動私のチャンネルに私のイベントを受け取ります。 setState
メソッドは状態を変更しません(またはコンポーネントは再描画しません)。私はイベント機能でsetState
メソッドを使用しているからだと思う..プッシャーからイベントを受け取ったときにどうすればModal
を閉じることができますか?