Invalid handling of ref objects (branch 'hooks')
mcjazzyfunky opened this issue · comments
[Edit: The initial issue description was wrong => description has been updated]
The current
property of ref objects will not be set to null
when the referred DOM elements are unmounted.
Please see the correct behavior in DIO and React here and the wrong behavior in Dyo here (please open JS console):
DIO: https://jsfiddle.net/73opa4fm/
React: https://jsfiddle.net/ovthf68L/
Dyo: https://jsfiddle.net/zvqa607h/
There aren't function refs in that branch(hooks), only useRef
.
But we should probably do the same for useRef
objects with obj.current = null
Ooops, sorry, I think I made a mistake: In my demo I've used my own implementation of useImperativeHandle
, which seems to be buggy.
Yes, you are right we should do the same with useRef
. I will check again tomorrow.
.... to be continued ....
@thysultan
Nevertheless there is something wrong with ref callbacks on normal DOM elements => I've updated the issue description above.
Or does that mean, that in Dyo callback refs will not be supported, only ref objects?
Would it be possible to publish an alpha version of the "hooks" branch on npmjs.com?
It would be easier to provide demos then.
Yes, only ref objects.
Would it be possible to publish an alpha version of the "hooks" branch on npmjs.com
Done. Dyo@0.0.19
@thysultan Thank you very much for the information and the publishing of Dyo.
I've updated the issue description and title accordingly.
You'll find a little Dyo demo linked in the description that shows the wrong behavior.
@mcjazzyfunky Dyo@0.0.20 should have a patch for that. Thanks.
Great. Thanks a lot. My simple demo is working now.
I'll close this issue.