我学的是本土反应。我的index.js文件如下:
import React from 'react';
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import App from './App';
import configureStore from './src/store/configureStore';
const store = configureStore();
const RNRedux = () => (
<Provider store={store}>
<App />
</Provider>
);
AppRegistry.registerComponent('redux1', () => RNRedux);
现在,我的问题是:
“react”不在任何地方使用。那么,我为什么要把它进口到这里?如果我把它注释掉,那么我会得到一个错误“cant find variable:react”。
React Native需要它吗?如果是这样,那么为什么React Native没有导入它?背后有什么原因吗?
我了解我在使用组件时正在app.js文件中导入“react”。
谢谢您。
我找到了答案。我忘记了我在index.js文件中使用了JSX,为此我需要导入react。