DEV Community

Discussion on: useReducer() Hook: Let me dispatch it

Collapse
 
martinpham profile image
Martin Pham

I wouldn’t call it modern JS (btw this thing existed I think 10 years ago, called Object literals), also it’s worse & they are totally different things:

The OP uses switch case which is perfect for this case, since JS will create a jump table which has better performance.

But yours will create object everytime repeatedly.