嘿,我正在尝试在使用 react-native-router-flux 时获取当前场景键。
我的路线文件:
const AppRouter = connect()(Router)
class Routes extends Component {
render() {
function selector(props) {
console.log(props)
// GoogleAnalytics.trackView(props.navigationState)
return props.auth.isLoggedIn ? (props.auth.isVerified? 'home': 'authenticate') : 'authenticate'
}
const component = connect(state => ({
auth: state.auth,
}))(Switch)
return (
<AppRouter>
<Scene key="root" component={component} tabs selector={selector} hideNavBar hideTabBar>
<Scene key="authenticate" hideTabBar>
<Scene type="replace" key="login" title="Login" initial component={GradientBackground(LoginScreen)} hideNavBar/>
<Scene type="replace" key="register" component={GradientBackground(RegisterScreen)} hideNavBar/>
<Scene type="replace" key="forgotPassword" title="forgotPassword" component={GradientBackground(ForgotPasswordScreen)} hideNavBar/>
<Scene type="replace" key="emailConfirmation" component={GradientBackground(EmailConfirmationScreen)} hideNavBar/>
</Scene>
<Scene key="home" component={NavigationDrawer} type="replace">
{require('./scenes/home')}
</Scene>
</Scene>
</AppRouter>
)
}
}
export default Routes
如您所见,我正在尝试将当前场景名称发送到谷歌分析进行跟踪,但我似乎无法获得当前显示的场景密钥,有什么想法吗?