Open catmando opened 3 years ago
on my projet I fixed this problem by redefining props_changed?
def props_changed?(next_props)
return true if `Object.keys(#{@__hyperstack_component_native}.props).length` != next_props.length
props = Hash.new(`#{@__hyperstack_component_native}.props`)
next_props.each do |k, v|
next if v.is_a?(Proc) && props[k].is_a?(Proc)
return true if props[k] != v
end
return false
end
I am not really satisfied with Hash.new
A native solution would be better but I don't know how to check if a value is a Proc in javascript
@catmando Usually we do fires
for this kind of callback props instead of params
, right?
@princejoseph yes but i think fires is just syntactic sugar ontop of the base mechanism, so the performance issue will exists regardless.
More info on this from @adamcreekroad:
The problem is that some where along the line a proc object is being wrapped with an extra JS function as its being passed around this makes the proc look like a new proc object every time.
@catmando ah, makes total sense. I really liked that it has a seperate fires
for the component. Makes the component behaviour obvious in a glance.
Note: Spec is already written, and is being skipped in component_spec.rb
the two object_id's won't match, causing the child to be rerendered everytime the parent is rendered.
Clearly something is wrapping proc params, but not clear where this is happening.