preact-compat icon indicating copy to clipboard operation
preact-compat copied to clipboard

child visible property toggles from true to false without re-render

Open MichaelRando opened this issue 8 years ago • 8 comments
trafficstars

In my test project: https://github.com/MichaelRando/preact-rollup-bootstrap pressing button 'Test Dialog' displays a test dialog, by virtue of setting the state variable to true and the Dialog's visible property is set to said state. Clicking off or closing the dialog is expected to hide the dialog's view. When using react & react-dom, the dialog appears and disappears as many times as the user could want, successfully. When using preact & preact-compat, the dialog appears successfully, but closing / setting the visible state false has no effect. The Dialog component is not re-rendering as React compatibility would expect. This is a super basic test; not sure why this is happening.

MichaelRando avatar Feb 28 '17 00:02 MichaelRando

It is re-rendering, just it's not closing the dialog. this seems to be an incompatibility with rc-dialog / css-transition-group. I understand your frustration, but bear in mind that while the demo code might be basic, it's relying on a fairly large external library. The complexity/intricacy is hidden.

I've been debugging so far and haven't found much, I'll post back here when I do.

developit avatar Mar 01 '17 00:03 developit

Weird. I assumed it was vdom issue because I wasn't getting breakpoints (update/render) in the child upon parent state change. But I'm not surprised it's a tip of iceberg, otherwise nothing would work...

MichaelRando avatar Mar 01 '17 03:03 MichaelRando

this seems to be an incompatibility with css animation, I try to modify animation-duration to 0s, the rc-dialog is not re-rendering when close dialog.

https://github.com/ant-design/ant-design-mobile/blob/master/components/style/anim.less#L4

luolonghao avatar May 18 '17 03:05 luolonghao

I use chrome-devtools debug it, the cause is the className of animation is removed before remove the div element, so may be this is not preact bug.

luolonghao avatar May 18 '17 08:05 luolonghao

I found why remove element have delay, when remove setTimeout in the following code, the dialog is not re-rendering. @developit

// render-queue.js:10
(options.debounceRendering || setTimeout)(rerender);

luolonghao avatar May 18 '17 08:05 luolonghao

Yes. We need to switch back to Promise.then for denouncing.

developit avatar May 21 '17 06:05 developit

Yes. need to revert https://github.com/developit/preact/commit/78014124593997d749e50ea1291a3c18731f1fe4

luolonghao avatar May 22 '17 12:05 luolonghao

https://github.com/developit/preact/commit/576dda310a8e31e524fa2ecc803d6d406597c41e

luolonghao avatar Jun 26 '17 06:06 luolonghao