preactjs / preact

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

Home Page:https://preactjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Component don't rerender if prop changes in short period of time

beautyfree opened this issue · comments

Describe the bug
I don't know the reason, but looks like component don't rerender if prop changes in short period of time.
Just look on sandbox with react and preact below

To Reproduce
codesandbox.io/p/sandbox/young-architecture-6t4dzs

Expected behavior
Drawer opens like with react https://codesandbox.io/p/devbox/drawer-with-scale-forked-9pd3cx?file=%2Fapp%2Fmy-drawer.tsx%3A14%2C1

State updates are batched, so you can't count on multiple updates in a very close succession rendering on the "intermediate" state, even if you update them on different ticks of the event loop.

This is true in both react and preact, although the IRL effect may vary.

I have added logs and got this:

preact react
image image

preact has extra opened changed: false

maybe Vaul library has logic that works differently with preact, idk and it would be great to find a solution

Try deleting Drawer.Content. I then get the same result. Pretty sure it's just a race condition with the re-rendering engine.