onSubmit stripped for Forms
See original GitHub issueTrying to test a button that allows form submissions:
import React from 'react';
import { storiesOf, action } from '@kadira/storybook';
import Button from '../button';
storiesOf('Button', module)
.add('submit for a form', () => (
<div className="p4 center">
<form
onSubmit={ () => action('form submitted') }>
<Button type="submit">Submit</Button>
</form>
</div>
));
It seems that onSubmit
gets stripped when it loads in React Storybook. I’ve tried different combinations: wrapping it with a div, making it the root component, using a custom Form
component, etc. In all cases the onSubmit
is stripped out. Any idea what I’m doing wrong? Or are forms not supported by React Storybook?
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
onSubmit stripped for Forms · Issue #128 · storybookjs/storybook
It seems that onSubmit gets stripped when it loads in React Storybook. I've tried different combinations: wrapping it with a div, making it...
Read more >Formik onSubmit function is not working on my code
I ran into this problem and found that my validator was returning something that signaled to Formik the form was invalid, but no...
Read more >Using Formik to Handle Forms in React - CSS-Tricks
This is how the binding works: It handles form submission with onSubmit={formik.handleSubmit} . It handles the state of inputs with value={ ...
Read more >Code being stripped out of form tag | CKEditor.com Forums
HiSome of my client pages have forms in it. ... onsubmit="return FormCheck(this);" into the form tag. ... gets stripped our of the form...
Read more >Onsubmit not working! - JavaScript - SitePoint Forums
My onsubmit function is not working. My PHP file has two forms. Both form tags have an onsubmit attribute that links to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to pass in just the call to action() not a function that calls it:
This doesn’t prevent the default action on the form though, so the iFrame will reload. Not sure how you could handle this outside storing the created action:
@njcaballero all the 6.x changes should be backwards compatible, i.e.
action(x)(e)
should still work. if you’re getting a warning about package dependencies you can just installaddon-actions
as a dev dependency to your project. it won’t affect essentials.if you want to use the “new way” of doing things where
onX
is automatically filled in via args, it would look something like this (react example)