Home > Enterprise >  console.log in provider not printing
console.log in provider not printing

Time:01-31

I have an expo app that loads a provider:

export const AppProvider = ({ children }: { children: ReactNode }) => {
  console.log('Hello from app provider!!');
  const alertsBottomSheetRef = useRef<BottomSheetModal>(null);

  const dismissAlert = useCallback(() => {
    alertsBottomSheetRef.current?.close();
  }, []);

  const values = {
    alertsBottomSheetRef,
    dismissAlert,
  };

  // >>>>> return <AppContext.Provider value={values}>{children}</AppContext.Provider>;
};

If I load the app with the last line commented, I can see the console.log. I can also see any changes I made to the console.log. However, When I uncomment that last line, I don't get any console.logs. Any thoughts why?

CodePudding user response:

What I think why its not working because the AppContext.Provider is a context provider, and it does not log anything to the console. The purpose of a context provider is to provide data to components that are descendants of the provider. It does not render anything to the screen and does not log anything to the console.

CodePudding user response:

The issue was that I started the server with expo start and not expo start --dev-client. console logs now appear as expected.

  • Related