i have this code which works perfectly fine, but when i update something in the local storage my app doesnt get updated unless i reload the app. What i want to do is to automatically update the data in my app as soon as the data in chrome storage changes:
const [profiles, setProfiles] = useState([]);
useEffect(()=>{
chrome.storage.local.get(["profiles"], (result) => {
if (result.profiles) {
console.log(result.profiles);
setProfiles( result["profiles"]);
console.log(profiles);
}
});
},[])
//run every time when the data changes
useEffect(()=>{
chrome.storage.local.set({ "profiles": profiles });
console.log("running");
},[profiles])