Tell us what’s happening:
DOn t understand this at all…
Your code so far
const reducer = (state = 5) => {
return state;
}
const store;
const store = createStore(reducer);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
.
Challenge: Create a Redux Store
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Hi. You aren’t specifying what’s your error message, but looking at your code I can see something that surely will cause an error. This line:
const store;
Remember, variables declared with const keyword are read-only (https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword ), so basically you must assign it its value once you declare it.
By declaring it again, you are trying to “override” a read-only variable, which isn’t possible.
If you would like to re-asign or modify its value, you should be using let instead of const , but only once . Calling let twice with the same variable name also cause error. Same goes for const .