美文网首页
这些年踩过react-native的坑

这些年踩过react-native的坑

作者: 读书的鱼 | 来源:发表于2019-06-25 10:43 被阅读0次
1.坑之一

undefined is not an object (evaluating 'params.title')

Page2: {
    screen: Page2,
    navigationOptions: (props) => {
        const {navigation} = props;
        const {state, setParams} = navigation;
        const {params} = state; //更改这个地方
        return {
            title: params.title ? params.title : 'This is Page3',
            headerRight: (
                <Button
                    title={params.mode === 'edit' ? '保存' : '编辑'}
                    onPress={() =>
                        setParams({
                            mode: params.mode === 'edit' ? '' : 'edit'
                        })
                    }
                />
            )
        }
    }
},

改为:

const { params={} } = state;
2.坑之二

No bundle url present: when the React Packager tab is closed #14118

截图

解决办法:
方法一:

info.plist → information Property List → + App Transport Security Settings → + Allow Arbitrary Loads = YES

方法二:

 have found the easiest/quickest way to bypass this is to exit the app within the simulator (2 x Cmd + Shift + H) and re-launch.

相关文章

网友评论

      本文标题:这些年踩过react-native的坑

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