Answer the question
In order to leave comments, you need to log in
How to call another component on click?
Good afternoon! Let's say there is a component A, in which the button is rendered, and a component B, in which the render method returns a modal window. How can I call a modal window from component B by clicking on the button of component A?
Answer the question
In order to leave comments, you need to log in
class Parent extends React.Component {
state = {
someStateKey: false,
};
someHandler = () => {
this.setState({ someStateKey: true });
};
render() {
return (
<Wrapper>
<ChildA someHandler={this.someHandler} />
<ChildB stateKey={this.state.someStateKey} />
</Wrapper>
);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question