I had a problem using react-konva due to Dom element. When I tried to add a function to resize the screen of konva according to the size of the dom. I got this error thrown after adding layers.
const checkSize = contentRect => {
const { width, height } = contentRect;
stage.attrs({
width,
height
});
stage.batchDraw();
};
export default class Review extends React.Component {
constructor(props) {
super(props);
this.state = { stage: {} };
}
componentDidMount() {
const { values, colorValue } = this.props;
imageValue = values;
colourValue = colorValue;
this.state.stage = new Konva.Stage({
container: "container",
width: 0,
height: 0
});
window.addEventListener("resize", checkSize);
}
it throws an error at that stage
layer = new Konva.Layer();
stage.add(layer);
Error message: TypeError: stage is undefined