Reputation: 97
I have two empty states named stateA and stateB. I made two different api call and changed the the states to the response fetched (array of objects) using setStateA and setStateB accordingly.
Now i want to check if a particular item is present in both the states and if present add that item in a 3rd array and map that array later .
How to do this?
Upvotes: 0
Views: 52
Reputation: 99851
useEffect(() => {
/* compare here and store in stateC */
}, [stateA, stateB]);
Upvotes: 1