Extract State Logic to Redux; kinda triggered

Tell us what’s happening:
Ok so ive spent the last few days going though the redux part of front end libs and felt pretty good that i was getting a basic understanding but now have hit abit of a confusing step entering redux+react

in the redux phase stores were created muitiple times like this:

const reducer = (state, action) => {
// with a switch statement here or if checking action.type and returning some data based off that
}
const store = Redux.createStore(reducer)

now this next bit was called a 'review ’ so i should know it right, however the correct answer to the question just below and is very differnt than how we learnt it. now the other method doesnt pass for these challenges.

so what i want to know is this something directly differnt because we are now using redux with react?
with some other view libarys redux works with createStore but not with react and hence we have to declare everything differently or have i misunderstood something and shud go bak to the redux part?

Your code so far

let messageReducer = (state, action) => {
    return [...state, action.message] //missing any type checks 
}

let store = {
  state: [],
  getState: () => store.state,
  dispatch: (action) => {
    if (action.type === ADD) {
      store.state = messageReducer(store.state, action);    // this is all in the store creation since because of react?
    }
  }
};




Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0.

Link to the challenge:

That’s almost literally what Redux is, that thing defined as store. You wouldn’t need to define it normally, you’d just import Redux, then do createStore; in the challenges it’s been made available to you as Redux.createStore. I’m assuming that’s been done by the person who wrote the hint so that they didn’t have to import anything and could just check it worked straightaway in a browser or whatever. Just to reiterate, that’s almost exactly the same as Redux (the actual Redux code has a few more methods + some error checking, but that’s the core there), you can just use the same thing you were using beforehand.

Redux store has nothing to do with react - you initialize store the same way regardless of framework/library. Your first code looks correct and this is the way you should proceed :slight_smile: