React Native - Nothing was returned from render

前端 未结 2 1931
[愿得一人]
[愿得一人] 2021-01-19 22:22

My application is stored in /src/index.js but i also have a /App.js and a /index.js.

I don\'t know the difference between these and i think thats the reason im getti

相关标签:
2条回答
  • 2021-01-19 22:39

    You forgot to return the components

    const App = ({ dispatch, nav }) => {
        return(
            <Navigator
                navigation={addNavigationHelpers({
                    dispatch,
                    state: nav,
                })}
            />
        )
    };
    
    
    export default () => {
        return(
            <Provider store={store}>
                <AppWithNavigation />
            </Provider>
        )
    }
    
    0 讨论(0)
  • 2021-01-19 22:52

    Your default export is not returning anything :

    export default () => {
    
        <Provider store={store}>
            <AppWithNavigation />
        </Provider>
    
    }
    

    To return JSX with an arrow function you need to use () => ( <JSX /> ) or the equivalent with curly braces : () => { return ( <JSX /> ) } :

    export default () => (    
        <Provider store={store}>
            <AppWithNavigation />
        </Provider>
    )
    

    or :

    export default () => {
        return (    
           <Provider store={store}>
               <AppWithNavigation />
           </Provider>
       )
    }
    
    0 讨论(0)
提交回复
热议问题