Help us understand the problem. What is going on with this article?

componentDidUpdateでsetState()が実行できない?

More than 1 year has passed since last update.

「componentDidUpdateでsetState()が実行できない」っていう情報を先輩から教わりました。

メモです。
全く知らない情報 かつ なぜ禁止されているかがわからなかったので調べました。

このstack overflowに回答がありました。

You can use setStateinside componentDidUpdate. The problem is that somehow you are creating an infinite loop because there's no break condition.

要は無限ループになっちゃうよっていう意味ですよね。

componentDidUpdate()の中でsetState()すると、またcomponentDidUpdate()が動作してしまうから・・・っていう感じですよね。

言われてみれば確かに!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした