Replies: 1 comment
-
Hi @djmin43, as far as i know there is not much of a difference between those in your use case. I Personally prefer using an empty string for strings' related states, as it's so much easier to understand and just overall makes much more sense. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is more of a general react question more so than 'create-react-app' question; however, I just couldn't seem to find a discussion page for react.
Setting a default useState value is something we do pretty much everyday.
Let's say if the value is type of string, and your default state value doesn't really matter because it will be filled by some external api.
Would you put null or empty string? Does this make any difference?
const [userName, setUserName] = useState(null)
or
const [userName, setUserName] = useState('')
Which one looks like a better choice?
Beta Was this translation helpful? Give feedback.
All reactions