Answer the question
In order to leave comments, you need to log in
How to load an image into canvas?
How to load Image to full width/height of canvas in React? for example:
class PlanPage extends Component {
constructor(props) {
super(props);
}
componentWillMount() {
this.setState({
canvasA: {
canvasWidth: 800,
canvasHeight: 600
}
})
}
componentDidMount() {
this.props.getDataMap(); // возвращает объект с полями id,..,URL где лежит картинка
const { canvasWidth, canvasHeight } = this.state.canvasA;
this.canvasA.width = canvasWidth;
this.canvasA.height = canvasHeight;
}
......
<canvas
ref={canvasA => this.canvasA = canvasA} /> //сам канвас
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question