How can I use localstorage value of benchmarkActiveTab
in the dependency array? The value is changing in the localstorage but the useEffect
isn't running when the value changes
const [activeTab, setActiveTab] = useState(
localStorage.getItem("benchmarkActiveTab") || 0
)
useEffect(() => {
async function getBenchmarkTimes() {
// this function doesn't run
}
getBenchmarkTimes()
}, [activeTab])
I tried to make the useEffect
run when the localStorage.getItem('benchmarkActiveTab')
changes, but the useEffect doesn't run.