💡

ReactのuseContextは時代遅れ?

に公開

useContextに関する記事を漁っていたら、radditでuseContextはすでに時代遅れなHooksであると話題になっていました。

https://www.reddit.com/r/reactjs/comments/1h9qmr8/react_19_is_usecontext_obsolete_what_are_the/?tl=ja

どうやら、話題の元となったのは、React.jsの開発チームメンバーがXでツイートしていたことからだそうです。引用元@tweet

By the end of 2024, you’ll likely never need these APIs again:
• useMemo, useCallback, memo → React Compiler
• forwardRef → ref is a prop
• React.lazy → RSC, promise-as-child
• useContext → use(Context)
• throw promise → use(promise)
• <Context.Provider> → <Context>

今までcontextを扱うのにはuseContextを使っていましたが、useはHooksではなくReactのAPIのようです。Reactは1年もすれば技術もどんどん変わってくるので、キャッチアップが必要ですね。

Discussion