fac19 / week10-Chlat

https://lets-go-pokemon-battle.netlify.app/
1 stars 0 forks source link

Default state values #21

Open matthewdking opened 4 years ago

matthewdking commented 4 years ago

This is my first issue so lovely to meet you all 👋 such an amazing job on the project! I just spent the first 5 minutes just playing before I remembered I had to review!! This is super impressive for a first foray into React :star: :tada:


I could be wrong but to me it looked as though the default state in all stateful components was an empty string. I think this is fine if the value is going to be a string but I would normally opt for either something related to the state value. This gives the developer an idea of what to expect the value to be.

E.g.

React.useState(false) // if value is always a bool
React.useState([]) // empty array if likely to be an array
React.useState("") // empty string if value will be a string
React.useState(null) // otherwise I tend to use null for things like objects