I have this code, and I want to access the states of the Die
component. How can I do it?
EDIT:
I have the Die
class (component), and I want to access it's setImage
state function.
Let me put it another way: How can I access ANY value of the child component from the parent component?
function App() {
const Roll = () => {
console.log(dice[0].props.Die);
};
const dice = [<Die />, <Die />, <Die />, <Die />, <Die />];
return (
<div className="App">
<div className="dice">{dice}</div>
<button className="generate" onClick={Roll}>
Roll
</button>
</div>
);
}