scaleflex / filerobot-image-editor

Edit, resize, and filter any image! Any questions or issues, please report to https://github.com/scaleflex/filerobot-image-editor/issues
MIT License
1.27k stars 322 forks source link

how to use getCurrentImgDataFnRef correctly? #387

Closed hostingermanagerweb closed 1 month ago

hostingermanagerweb commented 9 months ago

I'm trying to create a button to get the data outside the default button but I don't know how to use the getCurrentImgDataFnRef property, can you help me?

AhmeeedMostafa commented 9 months ago

hello @hostingermanagerweb , here u are a quick helpful code for u in react,


const Editor = () => {
  const getImgDataRef = useRef();

  const getImgData = () => {
     if (typeof getImgDataRef.current === 'function') {
         const fnOptionsIfNeededFoundInDocs= {}
         const imgData = getImgDataRef.current(fnOptionsIfNeededFoundInDocs);
         console.log(imgData);
     }
  };

  return (
     <div>
       <FilerbootImageEditor
          getCurrentImgDataFnRef={getImgDataRef}
          // ...yourOtherConfigurations
        />
        <button onClick={getImgData}>Your custom button</button>
     </div>
  )
}