Having trouble setting the properties of an html canvas element in my didMount function. In React.JS the corresponding code would be something like
componentDidMount(){
this.canvas.width = 1000;
this.canvas.height = 1000;
this.ctx = this.canvas.getContext(‘2d’);
}
render(){
return(
<canvas
ref={(ref) => (this.canvas = ref)}
/>
)
}
Right now I have
type state = {
myCanvasRef: ref(option(Dom.element))
};
let setCanvasRef = (theRef, {ReasonReact.state}) => {
state.myCanvasRef := Js.Nullable.toOption(theRef);
};
let make = ( _children ) => {
…component,
initialState: () => {myCanvasRef: ref(None)},
didMount: (self) => {
self.myCanvasRef.width = 1000;
},
render: self => {
<canvas ref={self.handle(setCanvasRef)}> </canvas>
}
};
I keep getting:
This record expression is expected to have type ReasonReact.componentSpec('a, 'b, 'c, 'd, 'e)
The field myCanvasRef does not belong to type ReasonReact.self
Can anyone help explain what I’m doing wrong?