cara meneruskan fungsi sebagai alat peraga dalam reaksi dalam komponen fungsional
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}
/>
)}
</>
);
};
Difficult Dove