Eager State Initialiser (ARCH3307)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key typescript.react.eager-state-initialiser · Severity info · Category performance
React: flags useState(expensiveCall()) - the call runs on every render and only the first result is kept. The lazy form runs it once.
Incorrect
Section titled “Incorrect”const [rows, setRows] = useState(parseCsv(file));Correct
Section titled “Correct”const [rows, setRows] = useState(() => parseCsv(file));