React-dropzone: Passing more than 1 parameter to onDrop

Created on 22 Dec 2016  路  3Comments  路  Source: react-dropzone/react-dropzone

Hi,

Is there a way to accept 2 or more parameters in the onDrop method? I need to also pass an id from the current row of the table.

Most helpful comment

Here is an example:

<Dropzone onDrop={(accepted, rejected) => {this.onDrop(accepted, rejected, 'third')}}>
  <p>Drop files here...</p>
</Dropzone>

and your function could look like

onDrop(accepted, rejected, myArgument) {
  console.log(accepted, rejected, myArgument)
}

Hope that helps.

All 3 comments

You're passing a function that you own. Just make this function accept all needed parameters.

This is closed but the only answer is "You're passing a function that you own. Just make this function accept all needed parameters." - can you give a code sample? If I pass a parameter to my "function that I own" for the onDrop event it overwrites the 'files' parameter with my parameter and this is a no no....

Here is an example:

<Dropzone onDrop={(accepted, rejected) => {this.onDrop(accepted, rejected, 'third')}}>
  <p>Drop files here...</p>
</Dropzone>

and your function could look like

onDrop(accepted, rejected, myArgument) {
  console.log(accepted, rejected, myArgument)
}

Hope that helps.

Was this page helpful?
0 / 5 - 0 ratings