-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
I've created my first Svelte 3 component 🎉 and I'd like to share it. Unfortunately, I'm encountering an issue when importing it using the generated index.js
file: DOM element binding using the bind:this
attribute doesn't work apparently (or the way my component is exported is wrong maybe).
If I import my component in a Svelte application, it works fine because it reads the pkg.svelte
file.
However, in another environment which doesn't read the svelte
property, like CodeSandbox, it breaks. Basically, when onMount
is called, the element is not bound and I get Cannot read property 'addEventListener' of null
when trying to add a listener on it.
Demo of the issue: https://codesandbox.io/s/o443j977j5
My component source: https://github.com/ValentinH/svelte-easy-crop/blob/master/src/Cropper.svelte