I have two react applications, i.e. appA and appB(Both have thier own ReactDOM.render() method) and they generate different build files i.e. bundleA.js and bundleB.js respectively. These bundles are loaded in a third application i.e. container(a plain js app).
There are some common states shared between them using global/window variables. For instance,
window.pets = [
{name: 'dog'},
{name: 'cat'}
]
Let's say appA add/remove a pet to/from window.pets. It's updated in appA but not in appB. I tried using useEffect in both applications, as follow:
//object dependecy dependency
useEffect(()=>{
console.log(window.pets);
},[window.pets])
//Also tried stringyting object
useEffect(()=>{
console.log(window.pets);
},[JSON.stringify(window.pets)])
But it's not capturing the global state change in other application. Any suggestion will be helpful.