To listen to local storage value changes in React, we listen to the storage event.
For instance, we write
window.addEventListener("storage", (e) => {
this.setState({ auth: true });
});
to listen to the storage event by calling window.addEventListener with 'storage'.
And then we do whatever we want when it changes by calling it with a callback that runs when the event is triggered.