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

Options addon must be configured *after* the preview has rendered in React Native #1192

Closed
tmeasday opened this Issue Jun 5, 2017 · 14 comments

Comments

6 participants
@tmeasday
Copy link
Member

tmeasday commented Jun 5, 2017

As the addon channel is not created until render time in React Native (see #1191), we cannot call setOptions until after that has happened. In practice, this currently means in a setTimeout block:

const StorybookUI = getStorybookUI({ ... });
setTimeout(() => setOptions({ ... }), 1000);

Reproduction

#815 (comment)

@slorber

This comment has been minimized.

Copy link
Contributor

slorber commented Sep 11, 2017

Hi,

I'm not using RN but i got the error pointing to this issue after upgrading, is it normal?

@tmeasday

This comment has been minimized.

Copy link
Member

tmeasday commented Jan 16, 2018

@slorber -- sorry i missed this. I think this error can sometimes happen if your node_modules gets messed up and you have two versions of @storybook/addons, too.

@tmeasday

This comment has been minimized.

Copy link
Member

tmeasday commented Jan 16, 2018

We should see if #2711 can be used to resolve this.

@slorber

This comment has been minimized.

Copy link
Contributor

slorber commented Jan 16, 2018

Will check next time I work on my storybook, haven't updated it for a while

@FredyC

This comment has been minimized.

Copy link
Contributor

FredyC commented Mar 12, 2018

@tmeasday So is there some viable solution/workaround as of now? The #2711 has been merged, but I am not sure how that can be used actually.

@tmeasday

This comment has been minimized.

Copy link
Member

tmeasday commented Mar 13, 2018

@FredyC -- the workaround of calling from a timeout should still work.

I believe it turned out #2711 was an event from the manager side when the channel was created -- a similar change would be needed on the preview side to solve this issue (if I remember right). If someone is game to give it a go, it would be great! I think most of the core team doesn't use RN and is a little afraid to touch it, unfortunately.

@FredyC

This comment has been minimized.

Copy link
Contributor

FredyC commented Mar 13, 2018

Actually, I just updated all packages yesterday and suddenly it seems to be working without any change. I guess some other change might have fixed it?

"@storybook/addon-actions": "^3.3.15",
"@storybook/addon-links": "^3.3.15",
"@storybook/react-native": "^3.3.15",
@danielduan

This comment has been minimized.

Copy link
Member

danielduan commented Mar 23, 2018

can we verify that this has been fixed and close this ticket? @FredyC @tmeasday?

@FredyC

This comment has been minimized.

Copy link
Contributor

FredyC commented Mar 23, 2018

Well, it seems more like a random issue. Even with those updated packages, I have seen that error time to time so I ended up with the timeout workaround which seems to be working so far, but it would be nice to have a proper solution for that.

@Gongreg

This comment has been minimized.

Copy link
Member

Gongreg commented Mar 23, 2018

@FredyC, hey. You are correct that this is a random issue. And the fix shouldn't be difficult. I would like to say that we can add the event to fix this issue (I would personally do it), but I have already failed multiple times to finish the functionality I am currently working on. If nobody will take this issue I will fix it, but I can't guarantee when I will do it. Sorry for that.

@tmeasday

This comment has been minimized.

Copy link
Member

tmeasday commented Mar 24, 2018

@danielduan as far as I know this remains an issue. I have not quite been brave enough to touch RN (which i don't use personally day-to-day) to try and resolve it, but I suspect it wouldn't be very hard to fix.

@xeroxoid

This comment has been minimized.

Copy link

xeroxoid commented Apr 17, 2018

Any news on this? Keep randomly getting it all day long today.

@Gongreg

This comment has been minimized.

Copy link
Member

Gongreg commented Oct 7, 2018

Hey, sorry for no bringing up no information, this issue was buried deep.

#3903 will solve this issue.
The channel will be created as soon as you call getStorybookUI instead of in middle of react render.

So you will be able to call:

const UI = getStorybookUI({...});

setOptions({...})

and you won't have to use any timeouts.

@Gongreg

This comment has been minimized.

Copy link
Member

Gongreg commented Oct 18, 2018

The #3903 was merged into the master. In Storybook v4 this issue is solved.

@Gongreg Gongreg closed this Oct 18, 2018

@issue-sh issue-sh bot removed the todo label Oct 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment