0

I noticed that the function assigned in the action tag is being evaluated every time the form changes. I want to do something like this to capture form submissions:

      <form className='input-form'
        encType='multipart/form-data'
        action={this.getRequestUrl()}
        method='post'
        onSubmit={this.trackFormSubmission()}>

but it appears that the trackFormSubmission() is being evaluated on form change as well.

I'm using React.js if that's helpful.

4

1 回答 1

0

this.trackFormSubmission每次调用该render方法时都调用它。

你应该改变

onSubmit={this.trackFormSubmission()}>

onSubmit={this.trackFormSubmission}>
于 2015-07-20T19:27:50.877 回答