When the user switch from differenct tab in react, I want to clear the cached articles store in state, I define the artcle state using react hooks like this:
const Index: React.FC = (props) => {
const [localArticle, setLocalArticle] = useState(new Map<number, any>());
}
when the tabs changed, I want to clear the state like this:
const onChange = (key: string) => {
setLocalArticle(new Map<number, any>());
}
it seems did not work, after set artcle to the new map with 0 element, the legacy element still stay in the state. what should I do to clear the state? I tried to debugging, the set not override the map: