Created
August 2, 2018 17:56
-
-
Save meandavejustice/bd8f610788c5a900b316769f8f4780bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class NewsletterForm extends React.Component { | |
| constructor(props: NewsletterFormProps) { | |
| super(props); | |
| this.handleEmailChange = this.handleEmailChange.bind(this); | |
| this.handleSubmit = this.handleSubmit.bind(this); | |
| } | |
| componentDidMount () { | |
| if (this.form) { | |
| this.form.addEventListener("submit", this.handleSubmit); | |
| } | |
| } | |
| handleSubmit(evt: Object) { | |
| evt.preventDefault(); | |
| evt.stopPropagation(); | |
| if (typeof this.props.subscribe !== "undefined") { | |
| this.props.subscribe(this.props.email); | |
| } | |
| } | |
| render() { | |
| return ( | |
| <form className={ classnames("newsletter-form", { "newsletter-form-modal": this.props.isModal }) } ref={(el) => this.form = el} data-no-csrf> | |
| {this.renderEmailField()} | |
| {this.renderPrivacyField()} | |
| {this.renderSubmitButton()} | |
| {this.renderDisclaimer()} | |
| </form> | |
| ); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since moving to adding the event listener to actual element via
ref:When using the react's built in
onSubmitlistener, I get the error after thehttps://basket.mozilla.org/news/subscribe/log