MCPcopy Create free account
hub / github.com/dailydotdev/apps / useLayoutVariant

Function useLayoutVariant

packages/shared/src/hooks/layout/useLayoutVariant.ts:33–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31};
32
33export const useLayoutVariant = (): UseLayoutVariant => {
34 const serverVariant = useContext(LayoutVariantContext);
35 const { isAuthReady } = useAuthContext();
36 const isLaptop = useViewSize(ViewSize.Laptop);
37 const { isV2, isLoading } = useLayoutVariantFlag();
38
39 // The shell the mirrored route painted stands only until the flag can
40 // contradict it, so turning `layout_v2` off takes effect on this render
41 // rather than the next hard navigation. `isLaptop` is client-only and would
42 // contradict what the server painted, so it applies from the second render
43 // on: `isAuthReady` is false on the server and on the first client render,
44 // which makes it the hydration boundary.
45 if (serverVariant && isLoading) {
46 return {
47 isV2: serverVariant === 'v2' && (!isAuthReady || isLaptop),
48 isLoading: false,
49 };
50 }
51
52 return { isV2, isLoading: serverVariant ? false : isLoading };
53};

Callers 15

MainLayoutComponentFunction · 0.90
CustomFeedEmptyScreenFunction · 0.90
BookmarkFeedLayoutFunction · 0.90
FeedFunction · 0.90
MainFeedLayoutFunction · 0.90
ToggleClickbaitShieldFunction · 0.90
SearchControlHeaderFunction · 0.90
ReadingStreakButtonFunction · 0.90
useSquadDirectoryLayoutFunction · 0.90
SquadDirectoryLayoutFunction · 0.90
SidebarItemFunction · 0.90
SidebarFunction · 0.90

Calls 3

useAuthContextFunction · 0.90
useViewSizeFunction · 0.90
useLayoutVariantFlagFunction · 0.85

Tested by

no test coverage detected