Add note on how to submit a form#6594
Conversation
| > | ||
| > You can pass an array into the `value` attribute, allowing you to select multiple options in a `select` tag: `<select multiple={true} value={['B', 'C']}>`. | ||
|
|
||
| ### Submit form |
There was a problem hiding this comment.
Let’s change this to Submitting a Form
|
Thanks! I left a few comments but I agree we should add this. |
|
@gaearon I have slightly more mixed feelings about this PR. I tend to think it's probably sufficient to give the user a nudge in the direction of using refs, but a full fledged example here seems like overkill. Especially since there are many other equally valid use cases for using events. For instance, suppose you want to imperatively clear an uncontrolled component. I feel like I would just collapse this whole section into two sentences:
@gaearon Thoughts? I don't feel strongly one way or the other. It's just that attaching refs is intended as an escape hatch instead of an endorsed pattern, so a little side-note seems sufficient. |
|
I also had mixed feelings so I side with @jimfb. |
|
Good suggestion, that note would have been enough for me. I just stole those sentences, should the header be changed as well (beyond @gaearon's suggested change)? |
e6be99f to
da81b16
Compare
|
@SimenB updated the pull request. |
|
Yeah, we should probably update the header. The title "Imperative operations" sounds fine to me. |
|
Done |
|
👍 |
This is just me overthinking it coming from jQuery, but googling how to submit a form gave me nothing, so I thought I'd add this.
Our use case was solved when I took a step back and just put a submit button into the form (which is why I included that example as well), but I can see use cases for programmatically doing it, in all cases when a form is submitted without user input, or at least where the input is not pressing a button/link. And as mentioned, googling didn't give me anything.