Warning about Component not wrapped within a provider
CoinCoderBuffalo opened this issue · comments
My main app looks like this, and there are 2 constate providers: NotificationProvider, MessageProvider.
return (
<UserProvider>
<NotificationProvider>
<MessageProvider>
<MenuProvider>
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
</MenuProvider>
</MessageProvider>
</NotificationProvider>
</UserProvider>
);
On component screens, I am using constate hooks like this:
import { useMessageContext } from "../../context/MessageContext";
const { count } = useMessageContext();
Everything is working fine, but why do I see the warning?
Can you create a reproduction on CodeSandbox please? If it’s not possible, please paste the entire file contents together with the warning stack.
A common mistake that generates this error is putting the context hook in the same component as you use the Provider. But you’re saying that everything is working fine, so this might not be your problem.
I'm getting this warning as part of an enzyme test
@gone That means you’re not wrapping your test components with the Provider component.
Closing as I can't reproduce the original issue. If you provide a repro I'll re-open it.