Closed msjavan closed 4 years ago
Looking at the code it seems like this is the case. The animator needs to have a condition to abort when widget destroy method is called.
Fix incoming: https://github.com/os-js/osjs-widgets/pull/4
I've just published @osjs/widgets@3.0.2
that should fix this issue.
Let me know how it works out and close this issue :)
I cloned the "3.0.2" > run "npm install" > change the dependency in src/client/index.js but still not solved for existing widgets.
Can you share this setup ?
Also, did you rebuild afterwards ?
I'm also interested in how you reproduce this error.
My mistake! I forget to change dependency in MyWidget.js too. So I change it to: import {Widget} from '../osjs-widgets/index.js'; now got following error in the client side:
Uncaught TypeError: Class constructor Widget cannot be invoked without 'new' at new MyWidget (MyWidget.js:15) at Object.create (provider.js:82) at Object.onclick (provider.js:130) at Object.onclick [as click] (Menu.js:90) at HTMLDivElement.g (index.js:156)
you can see this by adding chart1 in my deployment
There's something wrong with your import statement most likely.
Also, you can just use the npm version -- you don't need to clone anything.
This problem still not solved, which one is correct for import:
import Widget from '../osjs-widgets/index.js'; or import {Widget} from '../osjs-widgets/index.js';
the former occurs following error:
TypeError: Super expression must either be null or a function inherits.js:5 _inherits inherits.js:5 MyWidget osjs.js:200 js MyWidget.js:12 Webpack 6 webpack_require js webpack_require checkDeferredModules
The correct usage with the official package is import {Widget} from ...
.
If you maybe could share your files here https://gist.github.com/ ?
And the contents of ../osjs-widgets/index.js
is the actual osjs-widgets repo ?
import './index.scss'; import WidgetServiceProvider from './src/provider'; import Widget from './src/widget'; import DigitalClockWidget from './src/items/digitalclock';
export { WidgetServiceProvider, Widget, DigitalClockWidget };
Looks OK. What happens if you remove the index.js
part of the path so that it loads the pre-compiled version instead ?
import Widget from '../osjs-widgets';
. . .
Uncaught TypeError: Class constructor Widget cannot be invoked without 'new' at new MyWidget (MyWidget.js:15) at Object.create (provider.js:82) at Object.onclick (provider.js:130) at Object.onclick [as click] (Menu.js:90) at HTMLDivElement.g (index.js:156)
You have to do import {Widget} from '../osjs-widgets';
The curly braces must be used when export
is used (and not export default
) .
sorry, It already was {Widget}, I wrote it above by mistake.
Can you paste the latest error message and update the gist ? Because line numbers no longer match up.
I update the gist, It seems that its working !
I think the problem was I didn't rpm run build @ osjs-widget, I did run "npm install" before
and "rendering tick bug" is resolved !
Great!
In the custom widget example, fps event keep working, even after removing the widget, until the next desktop reload.