This rule prevents infinite rendering loop bugs in React. The bug occurs when a hook setter function is called directly in the body of a component, because this changes the component’s state. When a component’s state is changed, re-rendering occurs.
Ensure that you do not directly call hook setter functions in components, and instead call them from an event handler.