Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap Avatar component in react-dropzone #99

Open
NgTienToan opened this issue May 9, 2022 · 3 comments
Open

Wrap Avatar component in react-dropzone #99

NgTienToan opened this issue May 9, 2022 · 3 comments

Comments

@NgTienToan
Copy link

I have an task wrap Avatar component in react-dropzone but I cant match it.
Thank u for read and comment!!!

@kirill3333
Copy link
Owner

@NgTienToan what is your problem?
as far as I see you can place Avatar component inside this example like

import React, {useCallback} from 'react'
import {useDropzone} from 'react-dropzone'

function MyDropzone() {
  const [image, setImage] = useState(null)
  const onDrop = useCallback(acceptedFiles => {
    // Do something with the files
   setImage(your image)
  }, [])
  const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop})

  return (
    <div {...getRootProps()}>
      <input {...getInputProps()} />
      <Avatar
          width={390}
          height={295}
          onBeforeFileLoad={this.onBeforeFileLoad}
          src={image}
        />
    </div>
  )
}

@NgTienToan
Copy link
Author

I tried to get image from callback in react-dropzone . But not match with onCrop in Avatar component

@NgTienToan
Copy link
Author

I created sanbox. Can u help me
https://codesandbox.io/s/sad-mcclintock-6tls06?file=/src/AvatarUpload.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants