React-Redux | Random Quote Machine - need help please

I get this error message when trying to use <Provider> inside ReactDOM.render()


here is my code:

Hi Mohamed,

Based on the screenshot you’ve provided, I can imagine your app doesn’t know what provider is. I can see that you’re declaring Provider on line 24, but that’s destructured from ReactRedux variable, and I don’t see (maybe it’s out of the screenshot) where it’s declared. So that would be the first thing I would check. Ideally you can import them at the top of the file, on line 1 and remove lines 23-24.

import React from 'react';
import {createStore} from "redux";
import {connect, Provider} from "react-redux";

It would also be the most helpful if you provide code samples via something like codesandbox, so whoever tries to help you can replicate the issue on their machine and check whether their solution to your problem works, without needing to set things up. It’s also a brilliant editor.

Hope this helps and let me know how it goes.

1 Like

@alanmynah thanks for your reply.

I’m using Redux and React-Redux cdn.
I’m importing them in the HTML file.
And it works for {createStore} as you can see I created a store with initial value of the state.
And I can get the state back using getState().
But Idk why It doesn’t work for React-Redux.

this is codepen link to the project

I recommend not to use script tags in your codepen project, but import everything via Pen Settings -> Javascript, then everything works fine.

If you still want to import it via script, the order is important:

   <script src=""></script>
    <script crossorigin src=""></script>
    <script crossorigin src=""></script>
    <script src=""></script>
    <script src=""></script>

Hope that will help!


Thank you :smile:
it worked