3
ちょっと、反応ネイティブルータフラックスを使用している間、現在のシーンキーを取得しようとしています。反応ネイティブルータフラックス、現在のシーンキーを取得する方法
私のルートファイル:
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
あなたは私が追跡のための分析をGoogleに現在のシーン名を送信しようとしているが、私は、現在表示されているシーンのキーを取得することができるように見えることはできません見ることができるように、何か案は?
を?私はそれが何であるか分からない: "return defaultReducer(state、action)"。 – Squeaky
カスタムレデューサーが仕事をしたら(私はGoogleアナリティクスのページ変更を追跡する手助けをしています)、状態とアクションをデフォルトの減速機に戻して、ルータはそれを魔法にしてアプリ内のビューを変更できます。 デフォルトのレデューサーはライブラリの一部です: 「react-native-router-flux」から{Scene、Switch、Router、Reducer}をインポートします – ospfranco
これは、次の例に基づいています:https://github.com/aksonov /react-native-router-flux/blob/b11a84962e4e4d9265770382b8859d21d1a12ea0/Example/Example.js – superquest