how to pass function as a props in react in functional components
function App() {
const [status, setStatus] = React.useState(false);
const [text, setText] = React.useState("");
const handleClick = () => {
this.setStatus(prev => ({ status: !prev.status }));
};
const handleChange = e => {
this.setStatus({ text: e.target.value });
};
return (
<>
<button onClick={handleClick}>Open photo entry dialog</button>
<ChildComponent
isOpen={status}
text={text}
handleChange={handleChange}
handleClick={handleClick}
/>
</>
);
}
const ChildComponent = ({ isOpen, text, handleChange, handleClick }) => {
return (
<>
{isOpen && (
<Model
status={isOpen}
handleClick={handleClick}
text={text}
handleChange={handleChange}
/>
)}
</>
);
};