solid icon indicating copy to clipboard operation
solid copied to clipboard

`<Dynamic>` element registers reactivity in ref callback, may cause unexpected tracking and re-renders.

Open LiQuidProQuo opened this issue 3 years ago • 0 comments

Describe the bug

Reactivity is tracked on the ref callback of <Dynamic> element. The element re-renders, when signal count() changes.

function functionWithReactiveSideEffects(){
   count() // read signal
}
<Dynamic component="h3" ref={functionWithReactiveSideEffects}></Dynamic>

A regular element does not re render when count() changes

<h3 ref={functionWithReactiveSideEffects}></h3>

Your Example Website or App

https://playground.solidjs.com/?hash=1870300497&version=1.4.1

Steps to Reproduce the Bug or Issue

see repro

Element case

"reRender A" will only show once

dynamic element case

"reRender B" will show multiple times

Expected behavior

Dynamic element and a Element, should behave the same?

Screenshots or Videos

No response

Platform

playground

Additional context

discussion: https://discord.com/channels/722131463138705510/1005916405096529980 reported: greencactus

LiQuidProQuo avatar Aug 07 '22 22:08 LiQuidProQuo