Skip to content

Conversation

@jaylandro
Copy link
Contributor

Adding event.preventDefault(); to the handleSubmit method prevents the browser from submitting the form via standard mechanisms in turn engaging and demonstrating React mechanisms.

Adding event.preventDefault(); to the handleSubmit method prevents the browser from submitting the form via standard mechanisms in turn engaging and demonstrating React mechanisms.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@jwngr
Copy link

jwngr commented Apr 8, 2016

Thanks for the PR @jaylandro!

It looks like the function already calls return false which will prevent the default behavior. See this Stack Overflow post for some discussion on this.

Side note: you are calling event.preventDefault() without including event as an input argument to handleSubmit(). So that will end up throwing one of those dreaded "undefined is not a function" errors.

The example should work as expected already. Are you seeing weird behavior? If so, re-open this PR and let me know what browser you are using. If you can deploy the code somewhere live which shows the issue, that would be super handy.

@jwngr jwngr closed this Apr 8, 2016
@jaylandro
Copy link
Contributor Author

Behavior can be witnesses here: https://firereact-comment.firebaseapp.com/ and you are so right on passing the event, I had created this PR quickly directly in github but failed to pass the event in, as I had in my other project.

Browser: Chrome/49.0.2623.110
OS: OS X 10.11.2

Thanks

Passed in the click event for preventDefault on handleSubmit
@jaylandro
Copy link
Contributor Author

Documentation for React v0.12 notes that return false is deprecated in favor of preventDefault.
https://facebook.github.io/react/blog/2014/10/28/react-v0.12.html

@jwngr jwngr reopened this Apr 8, 2016
@googlebot
Copy link

CLAs look good, thanks!

@jwngr
Copy link

jwngr commented Apr 8, 2016

Thanks for linking to the change log. It's interesting that they deprecated return false. I've re-opened this PR and I'll accept this PR if you do the following:

  1. Add event as an input argument.
  2. Remove the return false; line at the end. It doesn't do what we want anyway so let's just rip it out.

Thanks!

Passed event into handleSubmit, removed return false.
@jaylandro
Copy link
Contributor Author

Complete, thank you for your patience @jwngr

@jwngr jwngr merged commit 11d2687 into FirebaseExtended:master Apr 8, 2016
@jwngr
Copy link

jwngr commented Apr 8, 2016

🎉 Thanks for the PR! 🎉

@jwngr jwngr changed the title Update app.js Updated commentsBox example to use event.preventDefault() instead of return false Apr 9, 2016
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants