Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React-Native][5.1.X] addon-ondevice-notes crash on initial story selection #257

Closed
kenny-inthirath-pear opened this issue Jul 29, 2019 · 12 comments

Comments

@kenny-inthirath-pear
Copy link

Describe the bug
Using the Notes add-on for the INITIAL Story that is loaded crashes the app and throws a JS error

Any Story selected after the initial one WILL NOT crash

To Reproduce

  1. Go to 'ADDONS' on the INITIAL Story loaded
  2. Click on 'NOTES'
  3. See error TypeError: Cannot read property of 'selection' of null

Expected behavior
Should see the text passed in (or auto-generated notes)

Screenshots
(with bug and workaround)
StorybookNotes

Code snippets

// rn-addons.js
import '@storybook/addon-ondevice-notes/register';

...

// someStory.js
simpleComponentsStory.add('someName', SomeComponent, { notes: 'some notes'})

System:

Nexus 5X (Android 9.+) device emulator
Dev/debugging mode
"react-native": "0.59.8"
"@storybook/addon-backgrounds": "^5.2.0-beta.17"
"@storybook/addon-knobs": "^5.2.0-beta.17"
"@storybook/addon-ondevice-backgrounds": "^5.2.0-beta.17"
"@storybook/addon-ondevice-knobs": "^5.2.0-beta.17"
"@storybook/addon-ondevice-notes": "^5.2.0-beta.17"
"@storybook/react-native": "^5.2.0-beta.17"

System:
    OS: macOS 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
    Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
Browsers:
    Chrome: 75.0.3770.100
    Safari: 12.1.2

Additional context
No issues pre-migration on 4.1.6
Reproducible on 5.1.9 and 5.20-beta-17

@kenny-inthirath-pear kenny-inthirath-pear changed the title [React-Native] addon-ondevice-notes crash on initial story selection [React-Native][5.1.X] addon-ondevice-notes crash on initial story selection Jul 29, 2019
@ChuanxuMa
Copy link

meets the same error

@ChuanxuMa
Copy link

It's because your default component on initial has no any notes. To avoid it, suggest to add note on every component.

@stale
Copy link

stale bot commented Sep 6, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@perpetuatingcuriosity
Copy link

perpetuatingcuriosity commented Sep 20, 2019

Even if I add notes to every story I get TypeError: Cannot read property of 'selection' of null

    "@storybook/addon-ondevice-notes": "^5.1.11",
    "@storybook/addon-storyshots": "^5.1.11",
    "@storybook/addons": "^5.1.11",
    "@storybook/react-native": "^5.1.11",
    "@storybook/react-native-server": "^5.1.11",
    "react-native": "0.61.0-rc.2",

Can the workaround label be removed here?

@ghondar
Copy link
Contributor

ghondar commented Sep 21, 2019

in addon-ondevice-notes/src/register.js they have:

...
const { active, api } = this.props;

    if (!active) {
      return null;
    }

    const story = api
      .store()
      .getStoryAndParameters(this.state.selection.kind, this.state.selection.story);
    const text = story.parameters[PARAM_KEY];
...

where active prop validates the getStoryAndParameters operation, but active props first time is true and the state isn't created, I added this line below if conditional

...
if (!active) {
   return null;
}

if (!this.state) {
   return null;
}

to make sure it comes with data before rendering the view.

@ghondar
Copy link
Contributor

ghondar commented Sep 21, 2019

here my pr storybookjs/storybook#8152

@stale
Copy link

stale bot commented Oct 14, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@Gongreg
Copy link
Member

Gongreg commented Nov 3, 2019

This issue is already fixed in 5.3.0-alpha.37 . Closing it.

@Gongreg Gongreg closed this as completed Nov 3, 2019
@Gongreg
Copy link
Member

Gongreg commented Nov 3, 2019

I am taking it back, the issue still persists. Creating a PR.

@Gongreg Gongreg reopened this Nov 3, 2019
@shilman
Copy link
Member

shilman commented Nov 5, 2019

Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.39 containing PR storybookjs/storybook#8692 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Nov 5, 2019
@leotm
Copy link

leotm commented Aug 23, 2021

jus curious how to fix on preview screen on 5.3

"@storybook/react-native": "5.3.25",
"@storybook/addon-notes": "5.3.21",
"@storybook/addon-ondevice-notes": "5.3.23",
Simulator.Screen.Recording.-.iPhone.12.-.2021-08-23.at.18.53.18.mp4

the rest work well (besides need to switch tab to update)

Simulator.Screen.Recording.-.iPhone.12.-.2021-08-23.at.18.54.12.mp4

(repro repo)

@shilman shilman transferred this issue from storybookjs/storybook Aug 24, 2021
@dannyhw
Copy link
Member

dannyhw commented Aug 24, 2021

@leotm the issue you are commenting on is a very old one, not sure it would be the same issue. I appreciate you providing a repro though that will help with discovering the problem.

I'll take a look when I can, however I'll probably open it as a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants