Trouble using Redux in Codepen.io

Trouble using Redux in Codepen.io
0

Hi FreeCodeCampers!

I’ve just finished the Front End Libraries Lessons and am trying to get started with the challenges in Codepen.io. I want to use Redux (with React) for practice, even though I know this is probably overkill for some of these projects, as I’m struggling to get my head around Redux and think applying it in practice might help.

I was having trouble getting Redux to do anything in Codepen.io, so just to make sure it was working properly I created a new pen and copied over some code from one of the challenges from the lessons that was working successfully. I added ReactDOM.render and created a HTML element but haven’t changed anything otherwise, and it’s still not working.

I think I have all the necessary external scripts etc but I’m sure I’m missing something obvious. I tried adding ‘import’ lines but that didn’t seem to help (and I was able to use React without doing this so I don’t think it should be necessary).

The browser console is throwing the following errors but I can’t figure out what they mean, even after Googling:

TypeError: S.createContext is not a function [react-redux.min.js:1:1052](https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js)

<anonymous> [https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js:1:1052](https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js)
<anonymous> [https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js:1:190](https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js)
<anonymous> [https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js:1:2](https://cdnjs.cloudflare.com/ajax/libs/react-redux/6.0.0/react-redux.min.js)

TypeError: connect is not a function [index.html:94:17](https://s.codepen.io/boomerang/iFrameKey-768f4879-fd1e-6aa3-5b46-b644f3568ac3/index.html?editors=1001)

<anonymous> pen.js:94:17

sendTimingEvent addSite start undefined undefined

Could anybody help me figure out where I’m going wrong so that I can get started on an actual challenge? Codepen link is below.

Thank you in advance!

Include the following at the top of your pen’s JS:

const { combineReducers, createStore} = Redux;
const { connect, Provider } = ReactRedux;

I ran into the same problem you’re describing, and this fixed it for me.
This pen is where I got the solution: https://codepen.io/swyx/pen/egdjQR