Storybook: Expecting a valid React element from the story with Knobs

Created on 30 May 2017  路  14Comments  路  Source: storybookjs/storybook

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"_

knobs bug needs reproduction

Most helpful comment

@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.

All 14 comments

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?

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.

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

@Gongreg,
Thanks :)

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

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

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

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

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.

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..

@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.

@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.

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

Fine with me 馃憤

Was this page helpful?
0 / 5 - 0 ratings