I'm trying to learn how to use the canvas in react via a package called react-konva. npm installation was simple enough, and I added some demo code that works...
// in MainComponent.js
import {Stage, Layer, Rect} from 'react-konva';
// in render()
<Stage width={700} height={70}>
<Layer fill={'red'}>
<Rect ... and so on
My code mentions Konva
in the context of getting a color...
Konva.Util.getRandomColor()
but my browser warns appropriately: "warning 'Konva' is not defined". I tried this...
import {Konva, Stage, ... } from 'react-konva';
but that makes things worse, generating undefined errors wherever I try to use Konva.
. I tried adding a reference directly to konva...
// in index.js
<script src="https://cdn.rawgit.com/konvajs/konva/1.3.0/konva.js"></script>
but then I get this error:
Konva instance is already exist in current eviroment. Please use only one instance.
(grammar error and misspellings in the original error message)
Would appreciate a pointer, or any thoughts about what might be causing this.