-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Question: Is it valid to test Redux-Form components? #113
Comments
Please correct me if I'm wrong, but the component we provide when adding stories will be rendered as the root component (source). So I guess it's easy to wrap it with a Provider component when adding stories. Something like this perhaps storiesOf('Button', module)
.add('with a text', withProvider(() => (
<button onClick={action('clicked')}>My First Button</button>
))) |
@mnmtanish Certainly. I was able to do something like let store = configureStore();
return (
<Provider store={store}>
<SimpleForm handleSubmit={handleSubmit} />
</Provider>); I just wasn't sure if that was idiomatic. Your |
Check this as well: #76 |
Just for reference, with the storiesOf('Button', module)
.addDecorator(getStory => (<Context>getStory()</Context>))
.add('with a text', () => (
<button onClick={action('clicked')}>My First Button</button>
)) |
I think we can close this now. |
also if anyone is having issues with the redux provider not being able to hot load, put it in another file than your config.js:
Provider.js:
That way when your |
I was facing the same problem, and applying what was indicated here kind of fixed it, but I get a different error message now: React.Children.only expected to receive a single React element child. I have this in my code:
where ActivityLog receives the property logs which is an array, and creates multiple children. But all wrapped with a single div. |
@alebrozzo i'm having the exact same issue
Seems to be in the Provider.render code |
ok i had to switch from the real Povider to the ReduxProvider in the story. |
for those getting React.Children.only you can wrap your provider output in a div to address the issue
|
I'm having a little trouble when I try to test a Redux-Form component in the storybook. The error I get is
Uncaught Invariant Violation: Could not find "store" in either the context or props of "Connect(ReduxForm(SimpleForm))". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(ReduxForm(SimpleForm))".
Which I imagine is because there's no
<Provider store={store}>
wrapping the storybook root. What I first want to check is if this is a valid use case for the story book, and if so, what the suggested best approach would be for getting redux-form to play nice in the storybook.The text was updated successfully, but these errors were encountered: