简体   繁体   中英

How to solve "Can't find variable: App" in React Native?

I am new to React Native and I don't understand how to solve this problem. I already installed react-native-gesture-handler . I am getting this error in the command:

Accessing view manager configs directly off UIManager via UIManager['getConstants'] is no longer supported. Use UIManager.getViewManagerConfig('getConstants') instead.

This is a part of the code:

import { createAppContainer, DrawerNavigator } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import Home from "./src/screens/Home.js";
import first from "./src/screens/first.js";
import React from 'react';

class App extends React.Component{
  render(){
    return(
      <RootStack/>
    )
  }
}

const RootStack = createStackNavigator ({

  Home:{screen:Home,
    navigationOptions: {
      header: null
     }},
  first:{screen:first,
    navigationOptions: {
      header: null
     }}

});

//const App = createAppContainer(RootStack);
export default App;

错误

I think this way is better:

const AppNavigator = createSwitchNavigator({
  Auth: {
    screen: Auth
  },
  Root: {
    screen: BottomTabNavigator
  }
})

const AppContainer = createAppContainer(AppNavigator)

const App = () => {
  return (
    <AppContainer />
  )
}

export default App

OR

if it didn't work then you better check your index.js file whether you imported App Component (Root component) correctly or not?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM