React's setState hook setter function should not be called directly in the body of a component, otherwise it would produce an infinite render loop. This can happen by mistake. Most commonly, the setter function is called from an event handler. == Noncompliant Code Example [source,javascript] ---- import { useState } from "react"; function ShowLanguage() { const [language, setLanguage] = useState("fr-FR"); // Makes an infinite loop setLanguage(navigator.language); return (

Your language is {language}!

); }; ---- == Compliant Solution [source,javascript] ---- import { useState } from "react"; function ShowLanguage() { const [language, setLanguage] = useState(navigator.language); return (

Your language is {language}!

); }; ---- == See * https://reactjs.org/docs/hooks-state.html[hooks-state] - React API reference