Found 1 error:
Error: Cannot call setState during render
Calling setState during render may trigger an infinite loop.
* To reset state when other state/props change, store the previous value in state and update conditionally: https://react.dev/reference/react/useState#storing-information-from-previous-renders
* To derive data from other state/props, compute the derived data during render without using state.
6 |
7 | if (true) {
> 8 | setPrevActiveDocName(activeDocName);
| ^^^^^^^^^^^^^^^^^^^^ Found setState() in render
9 | }
10 |
11 | return <div />
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCAyngIZ4IEC+BAZjBBgQOQwJVx4cBuADoA7UUygi+aCCIIAxNABsEAFW4IAFAEoioggTiywhYrzxoAbggAiEOADkqGOowC8JMnbhQXIvADCsrQAHng6wnKGxoQA2ljclgCC0tbeTi4ANARkeAAKiSkWafYZCAC6BB6kFNS0muZWtqXOCNqR+gRoTAQNqc2OrQQAhG4eCQjJ-emtusCdBrkFk0VNMy59xQNl7Z30op3ceLByADwAJlYEAPQAfKL7IiCZIEYiTGgA5igg81FCIAQIksaFYIj8eAByD0YhAlioSjQ5xoCAcEHICDwlBRAEkRAAlIHnBAwKEEPAwKAIPYPZ7gAAWEAA7njaDARAiwCgmJyEPQgA
Repro steps
Replace
if (activeDocName !== prevActiveDocName) {withif (true) {and you will receiveI expected to receive the same error when using the condition
if (activeDocName !== prevActiveDocName) {.cc @sleitor tagging you if it something that you want to fix based on your previous amazing contributions 🙏
How often does this bug happen?
Every time
What version of React are you using?
latest
What version of React Compiler are you using?
latest