Skip to content

observed data reverting back in mobx-react with bootstrap-4 #3394

Answered by kubk
cgokey asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, it's not related to Mobx. If you don't provide action attribute on a form, it sends the data to current URL thus reloading page: https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data#the_action_attribute

"If this attribute isn't provided, the data will be sent to the URL of the page containing the form — the current page."

You can fix it by providing onSubmit attribute to prevent form submitting:

<Form onSubmit={(e) => { e.preventDefault() }}>
  <Button onClick={this.addNewItem}>Add Another</Button>
</Form>

Here is a working example: https://codesandbox.io/s/adoring-sky-xrwbpd?file=/index.js

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cgokey
Comment options

Answer selected by kubk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants