Search code examples
reactjsavatar

React Avatar Editor not getting upload button


I am trying to use react-avatar-editor (https://www.npmjs.com/package/react-avatar-editor ) I have installed and import the component but I didn't get the button upload

Here is my simple component wher I used the Avatar Editor

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Nav from "./Nav";
import AvatarEditor from 'react-avatar-editor'


export default class EditProfile extends Component {



    render () {
        return (
           <div>
               <Nav logoUrl="logo_white.svg"  color="#D41F36"/>

               hello there
               <AvatarEditor
                   image="/imgs/A066.jpg"
                   width={250}
                   height={250}
                   border={50}
                   color={[255, 255, 255, 0.6]} // RGBA
                   scale={1.5}
                   rotate={0}
               />
           </div>
        )
    }
}

I should have this screen but I had this

please help out on this ?


Solution

  • react-avatar-editor doesn't handle the image selection. It deals specifically with the image crop, resizing and rotation of a given image. So you need to code something to get the image and pass to react-avatar-editor component.

    You can check how to do it here https://github.com/mosch/react-avatar-editor/blob/master/docs/App.jsx