Skip to content

object addon in @storybook/react-native is not working if results of object function are placed in a variable first #49

@joshglenn

Description

@joshglenn

Describe the bug
Object addon cannot be created using variable created with object(), only by direct function

To Reproduce
Try to create an addon like this:

let styleVar = object('CVStyle', {backgroundColor: 'red'}, 'GROUP-ID1');

storiesOf('ActionsScreen', module)
  .addDecorator(withKnobs)
  .add('default view', () => (
   <CenteredView style={styleVar}>
    <AppWithControllerim>
      <ActionsScreen actions={testActions} >
      </ActionsScreen>
      <Button onPress={action('clicked-a-button')}>Click Me</Button>
    </AppWithControllerim>
   </CenteredView>
  )
);

^ doesn't work. The knobs tab simply shows: NO KNOBS.

But this does work:

storiesOf('ActionsScreen', module)
  .addDecorator(withKnobs)
  .add('default view', () => (
   <CenteredView style={object('CVStyle', {backgroundColor: 'red'}, 'GROUP-ID1')}>
    <AppWithControllerim>
      <ActionsScreen actions={testActions} >
      </ActionsScreen>
      <Button onPress={action('clicked-a-button')}>Click Me</Button>
    </AppWithControllerim>
   </CenteredView>
  )
);

Expected behavior
Both cases should work the same.

Screenshots
If applicable, add screenshots to help explain your problem.

function result->variable->style prop

direct function result

System:
Please paste the results of npx -p @storybook/cli@next sb info here.

Environment Info:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.19.0 - /usr/local/bin/node
    Yarn: 1.22.0 - ~/.yarn/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 81.0.4044.122
    Firefox: 69.0
    Safari: 12.1.2
  npmPackages:
    @storybook/addon-actions: ^5.3.18 => 5.3.18 
    @storybook/addon-knobs: ^5.3.18 => 5.3.18 
    @storybook/addon-notes: ^5.3.18 => 5.3.18 
    @storybook/addon-ondevice-actions: ^5.3.18 => 5.3.18 
    @storybook/addon-ondevice-knobs: ^5.3.18 => 5.3.18 
    @storybook/addon-ondevice-notes: ^5.3.18 => 5.3.18 
    @storybook/react-native: 5.3.18 => 5.3.18 
    @storybook/react-native-server: ^5.3.18 => 5.3.18 
  npmGlobalPackages:
    @storybook/cli: 5.2.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions