I have some code in which a button in a child component triggers a function that lives in the parent component. A high level representation is as follows:
// File 1
const parentFunc = (param) => {
// does some things
};
const ParentComponent = () => {
const param = 1;
return (
<ChildComponent parentFunc={() => parentFunc(param)} />
);
};
// File 2
const ChildComponent = ({parentFunc}) => {
return (
<button onBlur={parentFunc}
);
};
Is there any way for this same onBlur event to also call a function that lives in the child component? For example, if the ChildComponent looked like this:
const Child = ({parentFunc}) => {
const childFunc = useCallback(() => {
// does some things
});
return (
<button onBlur={parentFunc}>Blur Me</button>
);
};