How To Disable PostHog When Developing Locally React Native

Forgetting to disable tracking when working in a local environment can add a lot of noise to your analytics data.

To disable tracking with PostHog, set the disabled property in PostHogProvider to the value of __DEV__.

tsx
export const RootLayout = () => (
  <PostHogProvider
    options={{
      disabled: __DEV__,
    }}
  >
    <App />
  </PostHogProvider>
);

Sources:

https://posthog.com/docs/libraries/react-native

https://reactnative.dev/docs/global-__DEV__