MostViewedFooter as an island - #3942
Conversation
|
Size Change: -85.4 kB (-6%) ✅ Total Size: 1.24 MB
ℹ️ View Unchanged
|
| switches={{}} | ||
| pageIsSensitive={false} | ||
| isDev={false} |
There was a problem hiding this comment.
I''m passing these in to be used by WithABProvider
|
|
||
| import { useApi as useApi_ } from '../../../lib/useApi'; | ||
| import { decidePalette } from '../../../lib/decidePalette'; | ||
| import { useApi as useApi_ } from '../lib/useApi'; |
There was a problem hiding this comment.
There's a bunch of these import changes which are merge conflict hangovers
jamesgorrie
left a comment
There was a problem hiding this comment.
Just a question that I think will help me with the review.
| format={format} | ||
| ajaxUrl={ajaxUrl} | ||
| /> | ||
| </WithABProvider> |
There was a problem hiding this comment.
Is this reason we need WithABProvider here because this is being loaded in dynamically and so doesn't inherit the BootReact WithABProvider?
There was a problem hiding this comment.
Yes, exactly. We're no longer in the same context (the same stack) as BootReact so we need to set our own AB provider
There was a problem hiding this comment.
Is this a pattern we will continue to see then and could we look at adding this to the islands code? e.g. All islands have the same as the Boot context?
(another PR / discussion maybe)
There was a problem hiding this comment.
I considered this approach (I'll update the PR description to include this) but it turned out to make the inclusion of this AB code dynamic (only when needed/wanted) I would have needed to change the code both in the Island server side component and also the doHydration client side code. It felt like adding more coupling to this for what is a secondary concern wasn't the right thing to do.
The alternative to the dynamic coupling is to just always set it. Which is an option. I guess the discussion is around the trade off between optimisation and dev ex. I think this is a worthwhile discussion to have so I'll raise it 👍
|
🏝️ #3629 |
What does this change?
Moves
MostViewedFooterinto an islandWhy?
Less javascript on initial page load
Why
MostViewedFooterLayout?I added this extra component so that we can have something to wrap with
WithABProvider. TheABProvidercomponent must wrap the component that wants to useuseABwhich in this case was happening at the root (inMostViewedFooter) so in this case we needed an extra layer of compositionDo we now need to manually insert
WithABProvider?This code introduces a pattern where we're asking developers to wrap their client side code with
WithABProviderwhere needed. But maybe we can incorporate this into the Islands abstraction itself? See this discussion