This repository was archived by the owner on May 20, 2022. It is now read-only.

Description
Error I'm getting in console:
Warning: Can't perform a React state update on an unmounted component.
This is a no-op, but it indicates a memory leak in your application.
To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Error location in hookstore code:
this.setters.forEach(function (setter) {
return setter(_this.state);
});
Here's the situation that fails:
PS! Also tried to pass dispatch/user store array directly to button as prop, same thing.
function Header() {
const [user, dispatch] = useStore('user');
return (
<div>
{/* other stuff.. */}
{user.loggedIn && (
<LogoutButton />
)}
</div>
);
}
function LogoutButton() {
// this component doesn't exist anymore after
// dispatch runs, hookstore still tries to update it?
const [user, dispatch] = useStore('user');
function logout() {
// sets user.loggedIn to false
dispatch({type: 'logout'});
}
return (
<button onClick={logout}>Logout</button>
);
}