找不到视图永久违反

时间:2019-05-26 12:36:44

标签: android ios react-native view react-navigation

我正在使用react-navigation在登录页面和注册页面之间导航。并且我在“登录视图”页面中遇到问题。

我看过这个'React Native Invariant Violation: View config',但没有得到答案。

在App.js中-

import Register from './src/pages/Register';

const MainNavigator = createStackNavigator({
  LoginPage : { screen : 'Login'},
  SignUp : {screen : 'Register'}
  }
);

const App = createAppContainer(MainNavigator);

export default App;

在Login.js中-

import LoginForm from '../components/LoginForm';

export default class Login extends Component{
    render(){
        const {navigate} = this.props.navigation;
        return(

                <View style = {styles.container}>
                <Logo />
                <LoginForm type="Log In"/>
                <View style = {styles.signupcont}>
                <Text>Not a User</Text>
                <TouchableOpacity>
                <Text style = {styles.signuptxt} 
                      onPress = {() => navigate('SignUp')}>Sign Up</Text>
                </TouchableOpacity>
                </View>
                </View>
        )
    }
}

我希望单击文本时会导航到“注册”页面,但显示“不变违反:未找到登录名的视图配置。”

1 个答案:

答案 0 :(得分:0)

屏幕不是字符串,而是页面类。

# If building docs, process Doxyfile.in into Doxyfile.
if test "x$enable_docs" = xyes; then
   AC_SUBST([CMAKE_CURRENT_SOURCE_DIR], ["."])
   AC_SUBST([CMAKE_BINARY_DIR], [".."])
   if test "x$enable_fortran" = xno; then
      AC_MSG_ERROR([--enable-fortran is required for documentation builds.])
   fi
   AC_SUBST([FORTRAN_SRC_FILES], ["../src/flib/piodarray.f90  ../src/flib/pio.F90  ../src/flib/pio_kinds.F90  ../src/flib/piolib_mod.f90  ../src/flib/pionfatt_mod_2.f90  ../src/flib/pio_nf.F90  ../src/flib/pionfget_mod_2.f90  ../src/flib/pionfput_mod.f90  ../src/flib/pio_support.F90  ../src/flib/pio_types.F90"])
   if test "x$enable_developer_docs" = xyes; then
      AC_SUBST([C_SRC_FILES], ["../src/clib"])
   else
      AC_SUBST([C_SRC_FILES], ["../src/clib/pio_nc.c ../src/clib/pio_nc4.c ../src/clib/pio_darray.c ../src/clib/pio_get_nc.c ../src/clib/pio_put_nc.c ../src/clib/pioc_support.c ../src/clib/pioc.c ../src/clib/pio_file.c ../src/clib/pio.h"])
   fi
   AC_CONFIG_FILES([doc/Doxyfile])
fi