shershen08 / vue-masonry

💠 Vue.js directive for masonry blocks layouting ✅
MIT License
673 stars 81 forks source link

Error Events.emit is not a function #121

Closed rosenfeldalon closed 2 years ago

rosenfeldalon commented 2 years ago

On version 0.14.0 using Vue 2 with TypeScript and composition API, when leaving component that uses vue-masonary gets the following error:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in directive masonry unbind hook: "TypeError: Events.emit is not a function"

shershen08 commented 2 years ago

Currency library is in transition mode supporting both Vue version 2 in version 3. However a composition API function is only available when you have version 3 explicitly used,

https://github.com/shershen08/vue-masonry/blob/93d83bb1230476d6f24b44c03e292e622ddc26da/src/masonry.plugin.js#L129

So the idea is you should not be using composition API functionality of vue-masonry with compatibility plugin on Vue 2

rosenfeldalon commented 2 years ago

Thanks for the quick reply, it seems that the error is caused on vue-masonry/src/masonry.plugin.js line 102 Events.emit(${EVENT_DESTROY}__${masonryId}) in the unbind function,

perhaps doing the checks you've done checking if Vue2 will solve this error: Events[${isVue2 ? '$' : ''}emit](${EVENT_ADD}__${masonryId})

Regards,

hollote commented 2 years ago

Please take a look at PR https://github.com/shershen08/vue-masonry/pull/123

shershen08 commented 2 years ago

merged, thanks

seonWKim commented 2 years ago

Is this fixed in version 0.14.0 ? I still see this error. Thanks in advance

rosenfeldalon commented 2 years ago

hey @shershen08 any thoughts on releasing a patch version with the fix? perhaps 14.1 will be much appreciated!

Regards,

shershen08 commented 2 years ago

@rosenfeldalon published 0.14.1 just now - https://www.npmjs.com/package/vue-masonry

please upgrade and give it a try

rosenfeldalon commented 2 years ago

@shershen08 Thanks! There is something strange with the version release, the version in npm is marked as 0.14.1 but the GitHub repo is still 0.14.0, the README.md file does show 0.14.1 but the masonry.plugin.js file with the fix on line 102 is not included...

shershen08 commented 2 years ago

When instal the new version is the problem fixed?

rosenfeldalon commented 2 years ago

no, as I mentioned the fix is not included in the masonry.plugin.js file as shown in the PR for some reason https://github.com/shershen08/vue-masonry/pull/123/files

this Is after removing node_modules before clean install

rosenfeldalon commented 2 years ago

@shershen08 perhaps there was something that went wrong in the merge, see attached screenshots, hope this will help clarify the situation:

shershen08_vue-masonry__💠_Vue_js_directive_for_masonry_blocks_layouting_✅

datomize-ui_–___Documents_datomize_projects_datomize-ui_node_modules_vue-masonry_src_masonry_plugin_js

Regards,

shershen08 commented 2 years ago

guys, will fix it today.

shershen08 commented 2 years ago

@rosenfeldalon @seonwoo960000 i've just published 0.15.0 please check if that is OK now?