react-native icon indicating copy to clipboard operation
react-native copied to clipboard

React Native, addon-links broken?

Open RWOverdijk opened this issue 6 years ago • 11 comments

Describe the bug

The links addon doesn't seem to work on React Native.

Undefined is not a function (near '...api.on...')

Simply followed the instructions.

api.on is in the docs though so I'm not sure why it's not working.

https://github.com/storybookjs/storybook/blob/next/addons/links/src/manager.ts#L7

To Reproduce

React native app with storybook 5.2.0-beta.0 and @storybook/[email protected]. Adding the import to rn-addons.js is enough, it throws the error.

Expected behavior

Links 😄

System:

  • OS: iOS
  • Device: iPhone X
  • Framework: React Native
  • Addons: links
  • Version: 5.2.0-beta.0

RWOverdijk avatar Jul 16 '19 12:07 RWOverdijk

Calm down github actions, I got this. Much love <3

RWOverdijk avatar Jul 17 '19 06:07 RWOverdijk

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!

stale[bot] avatar Aug 07 '19 07:08 stale[bot]

@RWOverdijk do you? :trollface:

shilman avatar Aug 07 '19 07:08 shilman

The addon is still broken.

@ndelangen, you've updated link addon to use global story store. React Native does not expose one.

Also React Native is not listening to SELECT_STORY event to update selected story, it actually emits this event itself so the web tree view would update when user select story through simulator.

Gongreg avatar Nov 03 '19 14:11 Gongreg

This issue is still around, as mentioned in the referenced one.

matteodanelli avatar Feb 05 '20 13:02 matteodanelli

Hi! I just ran into this issue, is there any workaround available (or an ETA for a fix)? Thanks!

FrenchSam avatar May 23 '20 18:05 FrenchSam

Also React Native is not listening to SELECT_STORY event to update selected story

FWIW, I confirmed that React Native will react to a SET_CURRENT_STORY event. This event requires a storyId, though, but that can be generated like follows:

import {SET_CURRENT_STORY} from '@storybook/core-events';
import { toId } from '@storybook/csf';
import {addons} from '@storybook/addons';

const story = {
  kindName: 'YourComponent',
  name: 'Basic',
};

addons.getChannel().emit(SET_CURRENT_STORY, {
  storyId: toId(story.kindName, story.name),
})

I'm not using the addon-links, but doing somehting similar on my own. But it sounds like either:

  • addon-links should emit SET_CURRENT_STORY instead of SELECT_STORY (what's the difference?)
  • alternatively maybe @storybook/react-native should be listening for SELECT_STORY

gobengo avatar May 31 '20 07:05 gobengo

Yo, still happens in 2021!

"@storybook/addon-links": "^5.3"

<Button status="danger" onPress={linkTo('RMS/Screens/Scan', 'scan serial number')}>
    Link test
</Button>

TypeError: undefined is not an object (evaluating '_global.STORYBOOK_STORY_STORE.getSelection')

JanithaR avatar Feb 09 '21 14:02 JanithaR

And 2022, still an issue

brandon-austin-lark avatar Apr 01 '22 15:04 brandon-austin-lark

I've never really used this addon so I'm not familiar with it. I will look into fixing it however it's not top priority on the list. If anyone wants to create a PR I'll happily assist etc.

Thanks 🙏

--

Edit: also make sure you are using version ~5 of the addon and not anything newer (6) or it's probably got no chance of working. Alternatively it might actually work in the 6.0 beta since it uses the updated event names though I don't know for sure.

dannyhw avatar Apr 01 '22 19:04 dannyhw

has this been fixed?

tobi1220 avatar Sep 26 '22 11:09 tobi1220