react-native
react-native copied to clipboard
React Native, addon-links broken?
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
Calm down github actions, I got this. Much love <3
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!
@RWOverdijk do you? :trollface:
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.
This issue is still around, as mentioned in the referenced one.
Hi! I just ran into this issue, is there any workaround available (or an ETA for a fix)? Thanks!
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
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')
And 2022, still an issue
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.
has this been fixed?