DEV Community

Discussion on: I Made My First Thing With React!

Collapse
 
cychainey profile image
Cy Chainey

Congrats,

Yep, the naming convention can take awhile to get used to emmet is a bit of a lifesaver for that.

It's an arrow function, although it just looks like syntactic sugar, it's the handling of this that makes it different from a standard function. If you look through the react docs you'll see that they write a standard function and then bind the functions this on to the component.

this.handleClick = this.handleClick.bind(this);

Using a function expression with an arrow function sets it's this to the component without the need to use bind(). There's much more to it than that lexical scope, implicit return etc. But this is a bit of a rabbit hole so I kept it relevant to your code. If you want a more in depth overview of how they work and when to use them check out the mdn docs.

Persisting data would require some kind of backend db. For something simple though localStorage works really well. I often use it when I'm prototyping something as it can operate as a fake backend to allow a change of UI (login successful etc). A good tut with reasoning can be found here. robinwieruch.de/local-storage-react/

Hope that was helpful, and congrats again.

Collapse
 
jackharner profile image
Jack Harner πŸš€

Super helpful. Thanks for the resources!