Events and Listeners
Currently events are handled using React's useEffect hook.
useEffect
React has a tutorial as well as documentation that can be found here.
Use effect allows you to run a function every time a state or context property changes.
The following example will run a function every time the user variable is updated,
useEffect(() => {
if (!!user) {
// do something here
}
}, [user]);
Lifting Up State
In some cases, you may not even need to use useEffect.