Cannot update a component while rendering a different component To locate the bad setState call

Опубликовано: 04 Октябрь 2024
на канале: Tech Nursery
23
0

Cannot update a component (`ExampleComponent`)
while rendering a different component (`MyComponent`). To locate the
bad setState() call inside `MyComponent`

when you try to update the state directly inside the render() method or function body, rather than inside a useEffect hook or a lifecycle method.To avoid this, make sure that any state updates or side effects are handled outside of the render phase, such as within useEffect.