Error when trying to access a state variable from a custom context hook