canvas上に絵が書けるcomponentをReactで作ってみました。 ポイント 書いている状態かどうかをstateで管理 contextの取得 this.refs.canvas.getContext('2d') offsetX,offsetYはnativeEventからアクセスする canvasのwidth/heightはcssではなくHTMLのプロパティで指定する コード import React, { Component } from 'react'; const style = { border: '1px solid gray', backgroundColor: 'white', }; class Canvas extends Component { constructor() { super(); this.state = { drawing: false }; } ge