INT
INT

Reputation: 912

Using React Dropzone together with React Final Form

Trying to figure out how to use these two components together. There's an issue on github that people refer to to get it up and running, but I can't figure it out. The gist of it is this:

<Field name={`logo`}>
  {(fieldprops) => (
    <div>
      <label>Logo</label>
      <Dropzone 
        onDrop={(files, e) => {
          props.change(`logo`, files);
          props.blur(`logo`);
        }}
      />
      <pre>{JSON.stringify(fieldprops, 0, 2)}</pre>
    </div>
  )}
</Field>

Using that exact code throws and error for me: TypeError: children is not a function

I've setup a reduced test case on Code Sandbox that uses hooks and file preview. I also tried looking at custom inputs in the docs, but seems like something is missing for it to work. Would be super happy if someone could point me in the right direction.

Upvotes: 1

Views: 4423

Answers (1)

Erik R.
Erik R.

Reputation: 7272

You don't have an onChange callback in your Dropzone component. How about this?

Edit gracious-star-xcbzk

Upvotes: 5

Related Questions