kensho-technologies / orama

Plug and play React charts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrate to React 16.3 lifecycle methods and refs

billyjanitsch opened this issue Β· comments

Now that v2 has dropped support for React < 16.3, we can use getDerivedStateFromProps and createRef. 🎈

The only work left here is moving away from componentWillReceiveProps in CanvasInput:

componentWillReceiveProps(nextProps) {
this.setState(prevState => {
if (!prevState.mouse || prevState.mouseLeave) return null
const solvedData = runHoverSolverOn(
getDataUnderMouse(nextProps, prevState.mouse, this.canvasRef.current)
)
return {...solvedData}
})
}