Comment

Comment by dreamdu5t

At first glance, hooks are hard to reason about. They encourage changing pure functions into stateful functions that return different results depending on when they were called.

Immediately after seeing the first example, I'm left wondering what happens if I called useState(0) twice? Does it produce references to the same state object or two separate ones? Does it throw an error? I see "count" and "setCount" being destructured, but where are they defined? Through static analysis during a special build step, through getters, or what?

parent dreamdu5t 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton