goodTime , im beginner at redux and when i setup that and use Provider in root.render it show me this Err :
Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
and Uncaught TypeError: Cannot read properties of null (reading ‘useMemo’)
it just for Provider component , if i dont call it i will don’t have this error.
thanks for helping me
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { Provider } from 'react-redux';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<Provider>
<App />
</Provider>
);
reportWebVitals();
i uninstalled the redux and npm package and then install them with last version but i have same problem
someone said maybe its for have same name in two package and it is confusing the computer but i dont think so
2
Answers
You need to pass the
store
to theProvider
I already made a comment, but to make it more visible, I am pasting this code snippet. Let me know if there is any other issue there?
The change is in this line