Reputation: 612
I'm trying to implement react-redux in my react-native application.
In my root index, I wrote :
import {createStore} from 'redux';
import rootReducer from './src/reducers';
import {Provider} from 'react-redux';
const store = createStore(rootReducer);
AppRegistry.registerComponent(appName, () => (
<Provider store={store}>
<App />
</Provider>
));
And the App looks like this :
const App: () => React$Node = () => {
return (
<>
<NavigationContainer>
<Stack.Navigator>
......
</Stack.Navigator>
</NavigationContainer>
</>
);
};
export default App;
But Metro server keeps giving me : [Wed Aug 12 2020 11:06:14.345] ERROR ReferenceError: Can't find variable: React
Upvotes: 0
Views: 55
Reputation: 612
Just added the reducers in App.js. And everything is now working fine.
Upvotes: 0
Reputation: 293
You need this line in the root index file
import React from 'react';
Upvotes: 1
Reputation: 16334
You have to import React in root index as well
import React from 'react';
This is not required in normal scenarios but as you are using jsx tags in root index this is required. Or you can do the provider setup in App.js
Upvotes: 1