Reactotron: Do not understand documentation about storybook switcher

Created on 29 Oct 2019  路  5Comments  路  Source: infinitered/reactotron

image

image

The documentation do not says where to use storybook imported from reactotron

Most helpful comment

My solution was to define a Reactotron "custom command":

// App.js

...

const AppRoot = () => {
  const [showStorybook, setShowStorybook] = useState(false)

  Object.defineProperty(global, 'showStorybook', {
    configurable: true,
    get() {
      return showStorybook
    },
    set(value) {
      setShowStorybook(Boolean(value))
      return Boolean(value)
    },
  })

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <Provider store={state}>
        {global.showStorybook ? <StorybookUI /> : <App />}
      </Provider>
    </SafeAreaView>
  )
}
// ReactotronConfig.js

...

Reactotron.onCustomCommand({
  command: 'storybook',
  handler() {
    global.showStorybook = !global.showStorybook
  },
  title: 'Toggle Storybook',
  description: 'Toggle between app and storybook',
})

All 5 comments

Can you show me your reactotron config?

I'm in the same boat - the example for using storybook doesn't not explain anything I can understand :-(

image

My solution was to define a Reactotron "custom command":

// App.js

...

const AppRoot = () => {
  const [showStorybook, setShowStorybook] = useState(false)

  Object.defineProperty(global, 'showStorybook', {
    configurable: true,
    get() {
      return showStorybook
    },
    set(value) {
      setShowStorybook(Boolean(value))
      return Boolean(value)
    },
  })

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <Provider store={state}>
        {global.showStorybook ? <StorybookUI /> : <App />}
      </Provider>
    </SafeAreaView>
  )
}
// ReactotronConfig.js

...

Reactotron.onCustomCommand({
  command: 'storybook',
  handler() {
    global.showStorybook = !global.showStorybook
  },
  title: 'Toggle Storybook',
  description: 'Toggle between app and storybook',
})

Seems like storybookSwitcher function is not defined at first. But if I wait like so setTimeout(() => console.tron.log(Tron.storybookSwitcher), 1). It is defined, but we can't register yet the App with AppRegistry.registerComponent...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eyesonly88 picture Eyesonly88  路  4Comments

sylar picture sylar  路  4Comments

felipemillhouse picture felipemillhouse  路  4Comments

nonameolsson picture nonameolsson  路  5Comments

ferminmoli picture ferminmoli  路  4Comments