[javascript] using enum in react!

hansol yang
1 min readFeb 23, 2020

--

if you need to conditional rendering, enum is a good choice!
react can do conditional rendering in several ways.
For example, if, if-else, ternary operator, switch..
They are a good way too. however, enum was especially has strength when you check conditions between multiple options.
that case, nomally using switch. switch is also good. but I think enum is little bit more concise.

but javascript hasn’t enum. so how do we use enum? basically, it takes advantage of object. More details is here! check that blog!

[reference]: https://www.robinwieruch.de/conditional-rendering-react

--

--

No responses yet