I have a misc.js wherein I have the following function which is meant to be used by several components:
export function loginCheck() {
const dispatch = useDispatch();
const user = useSelector((store) => store.user.currentUser);
!user && dispatch(showLoginPrompt());
}
However it throws:
Invalid hook call. Hooks can only be called inside of the body of a function component.
According to the examples of custom hooks in react native, hooks can be used inside plain functions not functional components, so I don't understand what's wrong here. Any help is much appreciated!