ブックマーク / overreacted.io (3)

  • 関数コンポーネントはクラスとどう違うのか?

    hc0001
    hc0001 2020/09/30
    “useCa”
  • useEffect完全ガイド

    あなたは Hooks を使って複数のコンポーネントを書きました。ちょっとしたアプリも作ったことがあるでしょう。満足もしている。API にも慣れて、その過程でコツも掴んできました。しかも重複したロジックを転用できるよう Custom Hooks を作り、同僚に自慢して見たり。 でも useEffect を使う度、いまいちピンときません。class のライフサイクルとは似ているけど、何かが違う。そしていろんな疑問を抱き始めます。 🤔 componentDidMount を useEffect で再現する方法は? 🤔 useEffect 内で正確に非同期処理を行う方法とは? []ってなに? 🤔 関数をエフェクトの依存関係として記すべき? 🤔 非同期処理の無限ループがたまに起こるのはなぜ? 🤔 古い state か props がエフェクト内にたまに入るのはなぜ? 私も Hooks を使

    hc0001
    hc0001 2020/02/11
  • A Complete Guide to useEffect — overreacted

    You wrote a few components with Hooks. Maybe even a small app. You’re mostly satisfied. You’re comfortable with the API and picked up a few tricks along the way. You even made some custom Hooks to extract repetitive logic (300 lines gone!) and showed it off to your colleagues. “Great job”, they said. But sometimes when you useEffect, the pieces don’t quite fit together. You have a nagging feeling

    hc0001
    hc0001 2020/02/11
  • 1