0
  const [ checks, setChecks ] = useState(props.list ? props.list.map(() => false) : []);

  useEffect(() => {
    setChecks(props.list.map(() => false));
  }, [ props.list ]);

props.list's length can be changed so i am using useEffect to update state. However, first time rendering component, useState works 2 times for initial value and setting in useEffect.

How can I handle this

hhh
  • 2,113
  • 3
  • 15
  • 32

0 Answers0