I am a beginner in React programming and I was following this tutorial in Youtube: https://youtu.be/hQAHSlTtcmY and everything went well until it w...
For further actions, you may consider blocking this person and/or reporting abuse
That video is old and the module is now exposed differently.
npmjs.com/package/uuid#create-vers...
I dont know what happen but now when I run Npm start I just get this error in the Terminal:
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactnative@0.1.0 start:
react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactnative@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Not sure, usually what I would do is
rm -rf node_modules
thennpm i
and thennpm start
OMG thanks, that fixed it! Now that I can actually run the build I can begin fixing this few errors :)
Can u help with these errors? I don't really understand what the issue even is here...
TypeError: localStorage.SetItem is not a function
C:/Users/sami/Git/Todo/src/App.js:16
13 | }, [])
14 |
15 | useEffect(() => {
localhost:3000/static/js/main.chun...
27 | if (storedTodos) setTodos(storedTodos);
28 | }, []);
29 | Object(react_WEBPACK_IMPORTED_MODULE_0_["useEffect"])(() => {
You should put code inside
Otherwise it's hard to read.
My guess is that
localStorage
is not defined.Try with
window.localStorage
as it exist only in the browser on the globalwindow
objectI tried that, but it gave me the same error in the Browser. I did it like this:
useEffect(() => {
const storedTodos = JSON.parse(window.localStorage.getItem(LOCAL_STORAGE_KEY))
if (storedTodos) setTodos(storedTodos)
}, [])
useEffect(() => {
window.localStorage.SetItem(LOCAL_STORAGE_KEY, JSON.stringify(todos))
}, [todos])
And sorry I don't know how to add that code field.
Try to make a reproducible example on Codesandbox, might be easier for people to help you
Also read dev.to/p/editor_guide
If you want to put the code you do it like this
I have the whole code in my Github :)
github.com/lolleri200/Todo/blob/ma...
it's
not
developer.mozilla.org/en-US/docs/W...
Ohh thanks! Works perfectly now :)
But there seems to be a bug that happens when I add a todo it adds 2 of the same items and when I try to remove it it gives me an error:
TypeError: toggleTodo is not a function
handleTodoClick
Ohhh thanks for the info! I'll give this a try :)
What's your file look like? Did you npm install uuid?
Yes I did that