DEV Community

Discussion on: Conditional rendering in React made easier and reusable "no library"

Collapse
diasbruno profile image
Bruno Dias • Edited

Great article. This "pattern match"-like style is really great to keep things organized (and remove some `if's).

To avoid rendering unnecessary elements, you can add a function.


mapping={{
[StateTypes.Init]: (props) => <Fragment/>,
...
}}