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

Expecting a valid React element from the story with Knobs #1160

Closed
MoctezumaDev opened this issue May 30, 2017 · 14 comments
Closed

Expecting a valid React element from the story with Knobs #1160

MoctezumaDev opened this issue May 30, 2017 · 14 comments

Comments

@MoctezumaDev
Copy link

Hi recently there was a change in the types definitios of

https://github.com/storybooks/storybook/blob/master/addons/knobs/storybook-addon-knobs.d.ts

withKnobs was converted to an interface and replaced by withKnobsOptions

This mismatches the documentation and also seems to break the functionality since even by replacing withKnobs by withKnobsOptions doesn't work, now I get an error:

Expecting a valid React element from the story: "foostory"

@Gongreg
Copy link
Member

Gongreg commented May 30, 2017

Hey, @leonidaX
I made that change. Sorry if it broke something, that means I made a mistake, since that update shouldn't have changed anything for current users. If you try to change withKnobs to previous definition, it works properly?

@MoctezumaDev
Copy link
Author

Yes it does, I replaced the storybook-addon-knobs.d.ts file with the previous revision in my node_modules and it works fine as before.

@Gongreg
Copy link
Member

Gongreg commented May 30, 2017

@leonidaX,
Thank you for checking it. Once again I am sorry. I will try to get this one working asap.

@MoctezumaDev
Copy link
Author

@Gongreg,
Thanks :)

@Gongreg
Copy link
Member

Gongreg commented May 30, 2017

@leonidaX,
I made a PR, can you take a quick look if that will work? I don't know how to properly test it.

@tmeasday tmeasday added the bug label May 30, 2017
@tmeasday
Copy link
Member

Maybe it would help to get a simple reproduction of the story that highlights the problem?

@Gongreg
Copy link
Member

Gongreg commented May 31, 2017

As I understand simply users using typescript and trying to use withKnobs were getting an error.

@MoctezumaDev
Copy link
Author

I downloaded the latest definition that you added in the PR and it's working.

@darekkay
Copy link

I'm also having problems with knobs now showing after updating the package version to 3.0.0. However, I get a different error(s):

WrapStory.js:74 Uncaught TypeError: Cannot read property 'removeListener' of null
    at WrapStory.componentWillUnmount (WrapStory.js:74)

and

KnobManager.js:111 Uncaught TypeError: Cannot read property 'emit' of null
    at KnobManager.js:111

Applying the PR didn't solve this problem.

After updating my code from .addDecorator(withKnobs) (as described in the readme) to .addDecorator(withKnobsOptions), I get no errors - but the whole story doesn't load anymore.

@Gongreg
Copy link
Member

Gongreg commented May 31, 2017

Hey, @darekkay,
It looks like addon fails to get channel inside storybook.
I never had this issue while working on this addon.
Maybe you could create a small example which gets this error?

Also if you want to use withKnobsOptions you have to call it like this:
.addDecorator(withKnobsOptions(optionsObject)).

But that will not change situation for you in this case..

@ndelangen
Copy link
Member

ndelangen commented May 31, 2017

@darekkay Please remove all node_modules and reinstall. After, check if there are any @kadira packages present. I have a suspicion you're using some addons still dependent on @kadira/addons.

@darekkay
Copy link

darekkay commented Jun 1, 2017

@Gongreg @ndelangen - Thanks for the quick reply! Removing and reinstalling node_modules solved the problem. I didn't have to apply the PR or change withKnobs to withKnobsOptions.

@Gongreg
Copy link
Member

Gongreg commented Jun 1, 2017

@darekkay Thanks, good to know! Can the close the issue now? :)

@darekkay
Copy link

darekkay commented Jun 1, 2017

Fine with me 👍

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

No branches or pull requests

6 participants