0

I am using useEffect with two dependicies

useEffect(() => { if(this is not the first time useEffect is called which means calls after componentDidMount){ //my operations } }, [props.inputs, props.inputLabels]); 

Is there a way to control this??

6
  • I can always use a variable state to control if this is the first time it entered but is there a better solution? Commented May 20, 2021 at 13:20
  • What is the actual question? You want what to happen? Run only once like in componentDidMount but with two deps? Thats the question? Commented May 20, 2021 at 13:25
  • 1
    Are you trying to make your code run only when you have an update in your dependencies? React hooks useEffect only on update? Commented May 20, 2021 at 13:31
  • reactjs.org/docs/… Commented May 20, 2021 at 13:36
  • Yes i am trying to run my code after update at my dependencies but not when the component first mount. Commented May 20, 2021 at 14:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.