Answer the question
In order to leave comments, you need to log in
How to call nested component methods?
Good evening, I have a class component that works with <canvas>
It implements all the necessary methods for rendering.
class Layout extends React.Component {
canvas = React.createRef();
// методы для отрисовки, отчистки и тп
draw = (x1, y1, x2, y2) => {
// рисуем линию
};
render() {
return <canvas ref={this.canvas />;
}
}
draw
this class method from parent components ? <Layout />
from parent components. <Layout />
and use it to manage the component. Answer the question
In order to leave comments, you need to log in
React.useEffect , where depending on the prop to pass, can help you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question