Fix marketplace tab reset state (#40601)
This commit is contained in:
commit
5c7698a9ad
|
@ -26,6 +26,7 @@ export default function Content(): JSX.Element {
|
|||
|
||||
// Get the content for this screen
|
||||
useEffect( () => {
|
||||
const abortController = new AbortController();
|
||||
if ( [ '', 'discover' ].includes( selectedTab ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -62,7 +63,7 @@ export default function Content(): JSX.Element {
|
|||
params.toString();
|
||||
|
||||
// Fetch data from WCCOM API
|
||||
fetch( wccomSearchEndpoint )
|
||||
fetch( wccomSearchEndpoint, { signal: abortController.signal } )
|
||||
.then( ( response ) => response.json() )
|
||||
.then( ( response ) => {
|
||||
/**
|
||||
|
@ -96,6 +97,9 @@ export default function Content(): JSX.Element {
|
|||
.finally( () => {
|
||||
setIsLoading( false );
|
||||
} );
|
||||
return () => {
|
||||
abortController.abort();
|
||||
};
|
||||
}, [ query.term, query.category, selectedTab, setIsLoading ] );
|
||||
|
||||
const renderContent = (): JSX.Element => {
|
||||
|
|
|
@ -60,14 +60,12 @@ const tabs: Tabs = {
|
|||
};
|
||||
|
||||
const setUrlTabParam = ( tabKey: string ) => {
|
||||
if ( tabKey === DEFAULT_TAB_KEY ) {
|
||||
navigateTo( {
|
||||
url: getNewPath( {}, MARKETPLACE_PATH, {} ),
|
||||
} );
|
||||
return;
|
||||
}
|
||||
navigateTo( {
|
||||
url: getNewPath( { tab: tabKey } ),
|
||||
url: getNewPath(
|
||||
{ tab: tabKey === DEFAULT_TAB_KEY ? undefined : tabKey },
|
||||
MARKETPLACE_PATH,
|
||||
{}
|
||||
),
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Fix content rendering issues with changing Marketplace tabs.
|
||||
|
Loading…
Reference in New Issue