I have a component as simple as this (auth.js -> inside screen/Auth folder) which isn't showing anything
import React, { PureComponent } from 'react'
import { View, Text } from "react-native"
class Auth extends PureComponent {
console.log('Inside Login')
render () {
return (
<View>
<Text> Login </Text>
</View>
)
}
}
export default Auth
My Auth screen should be displayed via react-route as my initial screen but unfortunately react is only showing blank (or white screen).
Note: The console.log in the above snippet is being logged
In, My app.js, I have this
import React, {Component} from 'react'
import {View} from 'react-native'
import AppNavigator from "./routes/routes"
export default class App extends Component {
render() {
return (
<View>
<AppNavigator />
</View>
)
}
}
Where my AppNavigator
looks like this
import {authNavigation} from "./auth"
import { createSwitchNavigator, createAppContainer} from "react-navigation";
const allRoutes = createSwitchNavigator(
{
authChecker: {
screen: authNavigation
}
},
{
initialRouteName: "authChecker"
}
)
const Navigator = createAppContainer(allRoutes);
export default Navigator;
And auth.js (in routes folder) looks like this
import AuthScreen from "./../screens/Auth/auth"
import { createStackNavigator } from 'react-navigation';
export const authNavigation = createStackNavigator(
{
Landing: {
screen: AuthScreen
}
},
{
initialRouteName: 'Landing',
}
)
Here AuthScreen
is the first code snippet
If this helps anyone,
In my app.js, I removed View
import React, {Component} from 'react'
import AppNavigator from "./routes/routes"
export default class App extends Component {
render() {
return (
<AppNavigator />
)
}
}
And It worked fine.
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.