Fang Jin
Aug 20, 2021

--

This is a great article.

However for the functional case, the conclusion isn't correctly drew.

Here's the reason

1) due to eager computation, the `setUser` doesn't cause a success dispatch. The reason is what you put as `object.is`. However this is not because the prop not getting changed, it's because the state is not getting changed

2) if the component ever gets rendered, you will see no matter what, WelcomeMessage gets rendered again. But as you mentioned `user` is a string, so in theory it can't be rendered right? But you explained this in the Class case.

So maybe overall you are right, but just want to point out the issue in the functional case.

--

--

Fang Jin
Fang Jin

Written by Fang Jin

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

Responses (1)