You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My bad, fixed. I've also just noticed that the public columns hash is actually included multiple times - once per mounted component! That's surely not helping the page size.
@sfcgeorge - so you are mounting multiple components in the view?
A short term fix that is easy but not elegant is to manually put in some erb method to dump the hash and then patch it out of the hyperstack code.
For ease of initial integration render_component runs assuming its the only one on the page, so dumps the hash. IIRC I could not find any way to only do it once so to speak but I could be wrong about that too.
If one copy of the hash is still too big, perhaps it gets rendered as a seperate asset in production and the whole gzip mechanism compress it?
Let me know if you need assistance, but I'll assume you can work around it for now?
All I can think for automatically doing the right thing is a request local variable (if there is such a Rails thing... https://edgeapi.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html) or maybe even just an ivar @columns_data_rendered = true. Or a manual option ala render_component(schema: false)
I added this patch to ComponentMount. Page size went from 739 KB to 317 KB, nice! An ivar feels a bit wrong but it works. (note it's the react_component method that's impacted by this, render_component in the controller is fine as there's only ever one).
Activity
Tim-Blokdijk commentedon Apr 14, 2019
I get a 404 on your gist link?
sfcgeorge commentedon Apr 14, 2019
My bad, fixed. I've also just noticed that the public columns hash is actually included multiple times - once per mounted component! That's surely not helping the page size.
catmando commentedon Apr 15, 2019
@sfcgeorge - so you are mounting multiple components in the view?
A short term fix that is easy but not elegant is to manually put in some erb method to dump the hash and then patch it out of the hyperstack code.
For ease of initial integration render_component runs assuming its the only one on the page, so dumps the hash. IIRC I could not find any way to only do it once so to speak but I could be wrong about that too.
If one copy of the hash is still too big, perhaps it gets rendered as a seperate asset in production and the whole gzip mechanism compress it?
Let me know if you need assistance, but I'll assume you can work around it for now?
catmando commentedon Apr 15, 2019
In the next point release we will do something to make this better:
sfcgeorge commentedon Apr 15, 2019
Yep, mounting multiple.
@columns_data_rendered = true. Or a manual option alarender_component(schema: false)sfcgeorge commentedon Apr 15, 2019
I added this patch to ComponentMount. Page size went from 739 KB to 317 KB, nice! An ivar feels a bit wrong but it works. (note it's the
react_componentmethod that's impacted by this,render_componentin the controller is fine as there's only ever one).catmando commentedon Apr 5, 2021
updated per @sfcgeorge suggestion:
hyperstack/ruby/hyper-component/lib/hyperstack/internal/component/rails/component_mount.rb
Line 45 in a39ae68