2017-08-10 11 views
0

反應本地路由器通量版本:3.39.1訪問時,用戶要一個場景組件狀態

嗨,我需要訪問組件的狀態時,導航欄上的後退按鈕,用戶點擊進入前一場景。 有沒有辦法做到這一點? 我需要這個來驗證狀態,如果用戶在任何textInput上做了一些工作。

回答

0

https://github.com/aksonov/react-native-router-flux/issues/647

如果使用「欺騙」是喬 - 朝倉說,你可以訪問組件的狀態onBack按鈕:)

// your scene 
<Scene key="someKey" 
     component={ SomeComponent } 
     onRight={ 
     (state) => { 
      // state.scene.navigationState.myData is { hello: 'world' } 
     } 
     } /> 

// your component 
class SomeComponent extends Component { 
    // ... 
    handleButtonClick() { 
    this.props.navigationState.myData = { hello: 'world' }; 
    } 
    // ... 
} 

PS:在我的情況我已經把這個線在渲染功能中始終保存新數據。

render(){ 
    this.props.navigationState.myData = this.state; 
     return() 
    } 
相關問題