atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.15k stars 43 forks source link

stale `useProp` values when passing data from parent to child #126

Closed WickyNilliams closed 6 months ago

WickyNilliams commented 6 months ago

Describe the bug I noticed that in a parent-child relationship, where the child accesses a prop via useProp, the prop's value can become stale/out of date.

Browser (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/atomico-use-prop-stale?file=src%2Ftest.tsx
  2. Click on the plus button
  3. Notice that the useProp value does not update in the child, whilst it does in every other place

Screenshots or video If applicable, add screenshots to help explain your problem.

Expected behavior The value returned from useProp should always match the value from the props arg passed to the component function

UpperCod commented 6 months ago

Ready 👍, bug fixed in atomico@1.76.1, Thanks for sharing your issue

WickyNilliams commented 6 months ago

Amazing thanks. I'll check if it fixes my issue and close this if so

WickyNilliams commented 6 months ago

Confirmed the issue is resolved in the stackblitz above. Thanks again!