import { useState, useRef, useEffect } from "react";
const useDebugRender = ({props}) => {
const prevProp = useRef(props)
useEffect(() => {
}, [])
}
const ParentComponent = () => {
const [random, setRandom] = useState(0); // Předává se jako Prop do dětského komponentu
const [text, setText] = useState(""); // Předává se jako Prop do dětského komponentu
const createRandom = () => setRandom(Math.floor(Math.random() * 100));
const onTextChange = (e) => setText(e.target.value);
const [count, setCount] = useState(0);
const incrementCount = () => setCount((prev) => prev + 1); // Tato funkce se předává jako Prop do dětského komponentu
return (
<>
<Count: {count} />
<input type="text" onChange={onTextChange} />
<button onClick={createRandom}>Vytvořit náhodně</button>
<div>
<ChildComponent
random={random}
text={text}
incrementCount={incrementCount}
/>
</div>
</>
);
};
export default ParentComponent;