Why is argument null not asignable to paramenter of type setStateAction in typescript?
I want to pass empty object as initial state for isAdmin
, but it's not assignable.
const Admin = () => {
const [isAdmin, setIsAdmin] = useState({});
useEffect(() => {
const user = getCurrentUser();
if (user && user.role === 'admin') {
setIsAdmin(user);
} else {
setIsAdmin(null);
}
}, []);
from Recent Questions - Stack Overflow https://ift.tt/2XYFbwU
https://ift.tt/eA8V8J
Comments
Post a Comment