score:-2

you attache your useeffect() with a props instead of attache it with a state value.

for fire the useeffect() event, you need to attach it with a state like this :

[show, setshow] = usestate(true);

useeffect(() => {

   // do stuff
}, [show]);

score:1

actually, use effect expecting possible state and props variable as it dependency array, because it has eslint rules defined for it.

useeffect is sensing that you have many props variable but you only using 1 (props.show) in dependency array. that why it is suggesting warning to add all or remove them.

solution

*

1- either add all of the props in the dependancy array like [props.show, props.hide ... etc]

*

2- or you can just ignore this warning by adding this line before dependancy array

useeffect(()=>{

// eslint-disable-next-line react-hooks/exhaustive-deps
},[props.show])

Related Query

More Query from same tag