美文网首页
ReactNative开发之react-navigation不集

ReactNative开发之react-navigation不集

作者: 漂泊_sbb | 来源:发表于2017-12-02 15:00 被阅读0次

    在不集成redux的情况下

    EditCover.js

    render() {
        const { state, navigate } = this.props.navigation;    
    
        return (
            <View>
                <Button title="Go to Page" onPress={ () => {
                    /* pass key down to *EditPage* */
                    navigate('EditPage', { go_back_key: state.key });
                }} />
            </View>
        );
    }
    

    EditPage.js

    render() {
        const { state, goBack } = this.props.navigation;    
        const params = state.params || {};
    
        return (
            <View>
                <Button title="Back to Cover" onPress={ () => {
                    /* go back from *EditCover* to *Cover* */
                    goBack(params.go_back_key);
                }} />
            </View>
        );
    }
    

    参考资料

    博客原文

    相关文章

      网友评论

          本文标题:ReactNative开发之react-navigation不集

          本文链接:https://www.haomeiwen.com/subject/dyunbxtx.html