I have a react file that has the next useState:
const [isEmpty, setIsEmpty] = useState(false);
in this file I have the next useEffect:
useEffect(() => {
//when the state of isEmpty is changed, do something
}, isEmpty);
I have a second react file that I would like also to have the same useEffect code, so I could do some stuff if the state of isEmpty is changed on the first file.
How can I so that?
I tried to export the useState but I get an error.
is there an easy way to share state between 2 react files?
can someone give share an example?