I want to call handleChange in my BasicInfos component from the Cropper function. Here's an example code:
export default function Cropper() {
return (
<Crop onChange={handleChange}/> // I want to call handleChange from here
);
}
import Cropper from "./Cropper";
@observer
class BasicInfos extends React.Component
{
@action
handleChange = (blob, url) => {
tmpFile = blob;
tmpFilePath = url;
}
render () {
return (
<Cropper action={this.handleChange}/>
);
}
}
You need to get the prop action
export default function Cropper({action}) {
return (
<Crop onChange={action}/> // I want to call handleChange from here
);
}
import Cropper from "./Cropper";
@observer
class BasicInfos extends React.Component
{
@action
handleChange = (blob, url) => {
tmpFile = blob;
tmpFilePath = url;
}
render () {
return (
<Cropper action={this.handleChange}/>
);
}
}