我的应用程序存储在/src/index.js中,但我也有/App.js和/index.js. 我不知道这些之间的区别,我认为这是我得到这个错误的原因. /index.js import { AppRegistry } from 'react-native';import App from './App';AppRe
我不知道这些之间的区别,我认为这是我得到这个错误的原因.
/index.js
import { AppRegistry } from 'react-native'; import App from './App'; AppRegistry.registerComponent('client', () => App);
/App.js
import App from './src/index'; export default App;
/src/index.js
import React from 'react'; import { AppRegistry } from 'react-native'; import { Provider, connect } from 'react-redux'; import { addNavigationHelpers } from 'react-navigation'; import Navigator from './routes/route'; import store from './store/configureStore'; const App = ({ dispatch, nav }) => { <Navigator navigation={addNavigationHelpers({ dispatch, state: nav, })} /> }; const mapStateToProps = state => ({ nav: state.nav, }); const AppWithNavigation = connect(mapStateToProps)(App); export default () => { <Provider store={store}> <AppWithNavigation /> </Provider> }
我使用create react native package来构建这个项目,然后尝试按照一些指南来实现与redux的反应导航.
您的默认导出不返回任何内容:export default () => { <Provider store={store}> <AppWithNavigation /> </Provider> }
要使用箭头函数返回JSX,您需要使用()=> (< JSX />)或带花括号的等价物:()=> {return(< JSX />)}:
export default () => ( <Provider store={store}> <AppWithNavigation /> </Provider> )
要么 :
export default () => { return ( <Provider store={store}> <AppWithNavigation /> </Provider> ) }