helix 2024-11-05

Hello everyone I encountered something weird while using helix and I wanted to ask if i'm going insane or the behaviour is something expected. Essentially passing a keyword as a property to another component causes the component to re-render every time something happens in the parent, because "it changed" even though value was the same.

(defnc Child [{:keys [data-type]}]
 ...)

(defnc Parent [{:keys [data]}]
 ($ Child {:data-type (if (is-composite data) :composite :normal)}))
In a setup like that, whenever data updates and causes the parent to re-render. It also causes the child to re-render. But what's curious is that according to profiler in react tools it specifically re-renders Because data-type prop changed, not because parent re-rendered. If you change the keywords to strings, profiler states that the component updated because parent updated. is the above expected flow or have I screwed up in the stack?

Browser profiler states that the value changes every time. Even if you strip the if out of the code and just pass a hardcoded keyword (or symbol 'composite for example. if doesn't cause it but the value type does

yeah that's expected. in development mode, keywords that appear inside of components are created every render

with advanced optimizations keywords are moved to a global table