Skip to content

Commit 0fdb8bb

Browse files
committed
Tweaked format for clarity
Prefer to inline the refetcher state so don't have to think about naming intermediate consts like ancestor
1 parent 121c16b commit 0fdb8bb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

NavigationReact/src/SceneRSCView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ const SceneRSCView = ({active, name, refetch: serverRefetch, errorFallback, chil
1717
const {state, oldState, data, stateNavigator: {stateContext, historyManager}} = navigationEvent;
1818
const {crumbs, nextCrumb: {crumblessUrl: url}, oldUrl, oldData, history, historyAction} = stateContext;
1919
const {deserialize} = useContext(BundlerContext);
20-
const {fetching: ancestor} = useContext(RSCContext);
20+
const rscContext = useContext(RSCContext);
2121
const sceneViewKey = name || (typeof active === 'string' ? active : active[0]);
2222
const getShow = (stateKey: string) => (
2323
active != null && state && (
2424
typeof active === 'string' ? stateKey === active : active.indexOf(stateKey) !== -1
2525
)
2626
);
2727
const show = getShow(state.key);
28-
const ignore = !!navigationEvent['ignoreCache'];
29-
const [{ancestorFetching, ignoreCache}, refetcher] = useOptimistic<any, void>({ancestorFetching: ancestor, ignoreCache: ignore}, () => ({ancestorFetching: false, ignoreCache: true}));
28+
const refetcherState = {ancestorFetching: rscContext.fetching, ignoreCache: !!navigationEvent['ignoreCache']};
29+
const [{ancestorFetching, ignoreCache}, refetcher] = useOptimistic<any, void>(refetcherState, () => ({ancestorFetching: false, ignoreCache: true}));
3030
const cachedHistory = !ignoreCache && history && !!historyCache[url]?.[sceneViewKey];
3131
if (!rscCache.get(navigationEvent)) rscCache.set(navigationEvent, {});
3232
const cachedSceneViews = rscCache.get(navigationEvent);

0 commit comments

Comments
 (0)