0

I'm using Konva in a Vue application, and I can't suppress Konva's warnings in browser console. According to Konva docs, there is an option for this, Konva.showWarnings = false. (I understood the warning itself and am aware of its possible implications).

I've checked this: Turn off Konvajs warnings, but to no avail, the answer here just explains that such a setting exists.

What I'm doing in my main.js file:

import VueKonva from 'vue-konva'
Vue.use(VueKonva)

and then I'm trying to apply the setting:

VueKonva.showWarnings = false

I've also tried adding it inside Vue.use as option:

Vue.use(VueKonva, {showWarnings: false})

...but to no avail.

What am I missing here?

zkriszti
  • 37
  • 1
  • 5

1 Answers1

1

You should do the same:

import Konva from 'konva';
Konva.showWarnings = false;

Are you sure you want to disable them?

edited: as the final solution to the problem, I'm adding @lavrton's comment from below: For the showWarnings property to work in vue-konva, you need to import both the original konva library, and the vue one for vue-bindings.

The working code now looks like this:

import VueKonva from "vue-konva";
import Konva from "konva";
Konva.showWarnings = false;

Vue.use(VueKonva);
Vue.use(Konva);
zkriszti
  • 37
  • 1
  • 5
lavrton
  • 18,973
  • 4
  • 30
  • 63
  • Yes, I need to disable them temporarily as I have thousands of nodes (the warning says that id is numeric, but it should be a string - I'll get back to fixing that). But first I'll need to resolve other issues, and allowing warnings makes initial render really slow, because the browser is dealing w/ the notifications. I created a minimalistic example, and I can reproduce the problem here: (see console for the warnings showing up despite the Konva.showWarnings = false statement). https://codesandbox.io/s/gallant-hellman-p4c56?file=/src/main.js – zkriszti Oct 21 '21 at 15:53
  • @zkriszti your demo is not the same that I proposed to do. – lavrton Oct 22 '21 at 14:24
  • it is a vue project, so I imported Konva as your doc states at https://konvajs.org/docs/vue/index.html - I need to import from 'vue-konva', otherwise the project will not work. – zkriszti Oct 22 '21 at 19:52
  • 1
    Import both. `vue-konva` for Vue bindings. And `konva` for other direct API. – lavrton Oct 23 '21 at 21:19