这是一个反应原生项目。 我正在使用 Redux 和 react-native-router-flux。
我的错误是这个 道具"布局"在"帐户"中标记为必需,但其值为"未定义">
在我的路线代码中,我有一个这样的场景,肯定在元素中传递"布局"。
<Scene
key="account"
title="Account"
icon={({focused}) => (<Icon name="heart-outline" type="MaterialCommunityIcons" style={[{ color: focused ? activeColor : inactiveColor }, { height: 30, width: 30 }]} />)}
navBar={() => <MyHeader onLeftPressed={Actions.pop} onRightPressed={Actions.addcards} text="Account" back={false} />}
{...DefaultProps.navbarProps} Layout={AccountComponent}
component={AccountContainer}>
</Scene>
当然,我已经包含了文件
import AccountComponent from '../components/Account';
这是"帐户容器"代码的一部分
const Account = ({
Layout,
locale
}) => (
<AccountComponent
locale={locale}
/>
);
我可以通过"布局"传递帐户组件而不是在上面的代码中显式编写它吗?但似乎"布局"是未定义的
另一个信息是,当我将页面切换到帐户时,我使用此代码切换页面。
_gotoAccount() {
Actions.replace('account');
}
我不知道这个替换动作是否清除了道具/改变了什么?
对于未来遇到此问题的人:确保场景中是否有键,这些键是唯一的。
我有两个场景使用相同的键,花了很多时间在一个愚蠢的问题上。