ChannelPage: Don't mount inactive ChannelContent
## Issue In the Channel Page, if the _Collections_ `claim_search` comes in after the main content's `claim_search`, the Collection's `ChannelContent` is being re-rendered despite not being in the active Tab. This causes a 0.4 CLS score (it's ridiculous that invisible components are taken into account). Apparently 41% of users are hitting this scenario, causing a poor aggregate. ## Change Don't mount the `ChannelContent` components unless its tab is the active one. It doesn't seem like Reach Tab hides components under the inactive tab.
This commit is contained in:
parent
f6e648222e
commit
077207e203
1 changed files with 18 additions and 14 deletions
|
@ -87,7 +87,7 @@ function ChannelPage(props: Props) {
|
|||
} = useHistory();
|
||||
const [viewBlockedChannel, setViewBlockedChannel] = React.useState(false);
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const currentView = urlParams.get(PAGE_VIEW_QUERY) || undefined;
|
||||
const currentView = urlParams.get(PAGE_VIEW_QUERY) || PAGE.CONTENT;
|
||||
const [discussionWasMounted, setDiscussionWasMounted] = React.useState(false);
|
||||
const editing = urlParams.get(PAGE_VIEW_QUERY) === PAGE.EDIT;
|
||||
const { channelName } = parseURI(uri);
|
||||
|
@ -288,14 +288,17 @@ function ChannelPage(props: Props) {
|
|||
</TabList>
|
||||
<TabPanels>
|
||||
<TabPanel>
|
||||
{currentView === PAGE.CONTENT && (
|
||||
<ChannelContent
|
||||
uri={uri}
|
||||
channelIsBlackListed={channelIsBlackListed}
|
||||
viewHiddenChannels
|
||||
empty={<section className="main--empty">{__('No Content Found')}</section>}
|
||||
/>
|
||||
)}
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
{currentView === PAGE.LISTS && (
|
||||
<ChannelContent
|
||||
claimType={'collection'}
|
||||
uri={uri}
|
||||
|
@ -303,6 +306,7 @@ function ChannelPage(props: Props) {
|
|||
viewHiddenChannels
|
||||
empty={collectionEmpty}
|
||||
/>
|
||||
)}
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<ChannelAbout uri={uri} />
|
||||
|
|
Loading…
Reference in a new issue