In the contentScript.tsx file I track storage changes, and if storage has changed, I show a specific component. But, when changing storage, this works for all tabs that are generally open, but I need to do it only for the active tab. How can this be implemented?
const App =() =>{
const [error, setError] = useState<boolean>(false)
useEffect(() =>{
chrome.storage.onChanged.addListener((changes,area)=>{
if(area==="local"&&changes.hasOwnProperty("isForbidden")){
const newValue=changes["isForbidden"].newValue
setError(newValue)
}
})
},[])
return(
<>
{error?
<>
<div>Ошибка</div>
</>
:null
}
</>
)
}
New contributor
Bereke Sakan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.