rn-async-storage-flipper icon indicating copy to clipboard operation
rn-async-storage-flipper copied to clipboard

Needs a way to embed only on dev mode

Open paulocf92 opened this issue 3 years ago • 1 comments

It would be cool if we could apply this plugin only in development mode, much like react-query-native-devtools does.

paulocf92 avatar Nov 16 '21 14:11 paulocf92

thats how @react-navigation/devtools is doing it

const noop: any = () => {};

export let useReduxDevToolsExtension: typeof import('./useReduxDevToolsExtension').default;
export let useFlipper: typeof import('./useFlipper').default;

if (process.env.NODE_ENV !== 'production') {
  useReduxDevToolsExtension = require('./useReduxDevToolsExtension').default;
  useFlipper = require('./useFlipper').default;
} else {
  useReduxDevToolsExtension = noop;
  useFlipper = noop;
}

For the time being I am doing this:

import UnsecureStorage from "@react-native-async-storage/async-storage"

let RNAsyncStorageFlipper: typeof import("rn-async-storage-flipper").default

if (process.env.NODE_ENV !== "production") {
  RNAsyncStorageFlipper = require("rn-async-storage-flipper").default
  RNAsyncStorageFlipper(UnsecureStorage)
}

export default UnsecureStorage

pke avatar Apr 07 '22 21:04 pke