WebReflection / uce-template

A Vue 3 inspired Custom Elements toolless alternative.
https://medium.com/@WebReflection/a-new-web-components-wonder-f9e042785a91
ISC License
108 stars 7 forks source link

event props fired at first render... #7

Closed tvardy closed 3 years ago

tvardy commented 3 years ago

Hi! Firstly, maybe I'm doing something wrong 😅 But here's the issue:

Demo commit: https://github.com/tvardy/js-playground/commit/47d709ec52d1f5806afce00354b424a7b3c494cf (npm i + npm start and you can see the demo page)

I was playing around with some lightweight and simple state management solutions being able to connect to micro-frontends.

If you look into clicker-stent.uce and clicker-preach.uce you'd be able to see 3 versions of connecting the store to the component.

Now, the problem is that the nicest looking version (b) does not work as expected. It fires the increase action immediately during the first render and that changes the global state.

I'm not sure why is this happening 🤔

tvardy commented 3 years ago

I found out that it only happens for props option... So the quick solution was to change a bit a structure of the components and change setup="props" to just setup.

https://github.com/tvardy/js-playground/commit/3d7bacbca66718296f04b18952ef06e4eaa7d178

WebReflection commented 3 years ago

Apologies I’ve had fever and felt sick last days, I haven’t managed to check your code.

however, if you found a specific props issue please file a bug with a minimal case and I’ll fix it