-
-
Notifications
You must be signed in to change notification settings - Fork 287
Closed
Description
I am trying to use React 16.3 Context API based on render props with React Konva:
import React from "react";
import { Layer, Stage, Circle, Group, Line } from "react-konva";
const { Consumer, Provider } = React.createContext({ width: 0, height: 0 });
const ToolsLayer = () => (
<Consumer>
{({ height, width }) => (
<Layer>
<Group offsetY={-height} y={-42}>
<Line
points={[0, 0, width, 0, width, 42, 0, 42]}
closed
stroke="black"
/>
<Circle radius={11} fill="red" stroke="black" x={21} y={21} />
<Circle radius={11} fill="green" stroke="black" x={21 + 42} y={21} />
<Group />
</Group>
</Layer>
)}
</Consumer>
);
export default function Canvas({
width = window.innerWidth,
height = window.innerHeight
}) {
return (
<Provider value={{ width, height }}>
<Stage width={width} height={height}>
<ToolsLayer />
</Stage>
</Provider>
);
}And I get runtime error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `ToolsLayer`.
Reproducible demo: https://codesandbox.io/s/2o9j1r6l30
himynameisdave, ryanquinn3, leMaik, terrierscript, gustavodemorais and 3 morehimynameisdave and oriolpuighimynameisdave, okathira and jaslioin
Metadata
Metadata
Assignees
Labels
No labels