2017-05-31 41 views
0

私はリアクションネイティブアプリにリアクタを使用しています。私がここで紛失しているかどうかはわかりませんが、私はreact-router-nativeをインストールし、履歴パッケージを必要とし、新しいルートをスタックにプッシュするいくつかの方法をセットアップしますが、何も起こりません。私はconsole.log( 'クリック');それが発砲していることを確認し、何が間違っているかを確認する必要があります。私はあなたのルータの設定を知らないが、あなたの方法があるべきリアクションルータv4でのナビゲーションネイティブでシーンが変更されない

import React, { Component } from 'react'; 
import { View } from 'react-native'; 
import Splash from './Splash'; 
import createHistory from 'history/createMemoryHistory'; 

const history = createHistory(); 

class SplashContainer extends Component { 
    goToLogin =() => { 
    history.push('/Login'); 
    } 
    goToRegister =() => { 
    history.push('/SignUp'); 
    } 
    render() { 
    console.log(history) 
    return (
     <Splash 
     goToLogin={this.goToLogin} 
     goToRegister={this.goToRegister} 
     /> 
    ); 
    } 
} 

export default SplashContainer; 

import React from 'react'; 
import { StyleSheet, View, Text } from 'react-native'; 
import { Button } from 'native-base'; 
import { Link } from 'react-router-native'; 
import PropTypes from 'prop-types'; 

const Splash = (props) => { 
    console.log(props) 
    return (
    <View style={styles.container}> 
     <Button light block onPress={props.goToLogin}> 
     <Text>Login</Text> 
     </Button> 
     <Button dark block bordered style={{marginTop: 10}} onPress={props.goToRegister}> 
     <Text>Register</Text> 
     </Button> 
    </View> 
); 
} 

Splash.propTypes = { 
    goToLogin: PropTypes.func.isRequired, 
    goToRegister: PropTypes.func.isRequired 
} 

export default Splash; 

答えて

0

goToLogin =() => { 
    const { history } = this.props 
    history.push('/Login'); 
} 

historyは、ルータのスタック内部の部品の小道具を経て受け継がれます。

関連する問題