Fairly new to React here. In a situation like this, I have 2 values referenced in the callback. I only want the callback to be executed when the first value changes. Because I reference the second value, it still needs to be in the dep array; however, I don't want the callback to be execute every time the second value changes because it would be pointless in my code.
useEffect(()=> {
// Do something with val1 and val2
}, [val1, val2]);
What is the best way to handle this situation?
I know useReducer exists, but I haven't learned it and I'm not sure if that is the solution to my problem.
UPDATE
I also know I can just add some logic inside the callback to return early if my val1 hasn't changed, but I was just wondering what the best approach is.