Can I update the deps array in useEffect?

Viewed 61

I am using Effect Hook and want to confirm if this implementation is correct. I am not getting any warning in the console but I want to know why this is not going into an infinite loop?

React.useEffect(() => {
    setSelections(inputUPC, false);
    //console.log(props.uncheckCard);
    props.setUncheckCard(false);
  }, [props.uncheckCard]);
1 Answers

It's not going into infinite loop because you only set this to false so there is no change in parameter (useEffect only trigger on dependencies values change)

Related