尝试使用4.0.0-beta.28开始使用超级简单的react-native-router-flux示例。我收到了可怕的红色屏幕,Action未定义。我猜我的语义不正确吗?
这是我的代码:
import React, {Component} from 'react'
import {Scene,Router} from 'react-native-router-flux';
import LoginScreen from '../shoppinglist/screens/login'
import LandingScreen from '../shoppinglist/screens/landing'
import {
Platform,
AppRegistry
} from 'react-native';
const MyApp = () => {
return (
<Router>
<Scene key={"root"}>
<Scene key="login" component={LoginScreen} title="Login">
</Scene>
<Scene key="home" component={LandingScreen} title="Home" initial></Scene>
</Scene>
</Router>
)
}
AppRegistry.registerComponent('shoppinglist', () => MyApp)
触发操作的代码:
<Button onPress={() => Actions.home()} title={'Navigate to Login'} />
答案 0 :(得分:1)
您在导入指令中缺少动作:
import { Actions, Scene, Router } from 'react-native-router-flux';