Fang Jin
Dec 22, 2020

--

I found it's not the `if` that you want to avoid. It's that `if` needs to be deferred so that they resolve itself in the future, not in the moment they are defined.

IMHO, `if` can't be avoided, no matter how you do it. It's the nature of a condition. `switch` is just a decoy. `states` is a generalizaton, but won't be abe to cover all edge cases.

--

--

Fang Jin
Fang Jin

Written by Fang Jin

Front-end Engineer, book author of “Designing React Hooks the Right Way” and "Think in Recursion"

No responses yet