perf: Avoid unmounting of Shell on navigation and thus reduce number of paints (#10646)
Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
37ce8860b5
commit
a49c34e733
17 files changed
+221
-158
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { useRef } from "react";
|
||||
|
||||
/**
|
||||
* Updates in document the number of times a component has been rendered. Helps in 2 ways. Using it doesn't cause any additional renders.
|
||||
* - Did the component render when it shouldn't have?
|
||||
* - Did the component reset its state when it shouldn't have?
|
||||
*/
|
||||
export const RenderCounter = ({ label }: { label: string }) => {
|
||||
const counterRef = useRef(0);
|
||||
counterRef.current++;
|
||||
return (
|
||||
<span>
|
||||
<span>{label}:</span>
|
||||
<span>{counterRef.current} </span>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export { RenderCounter } from "./components/RenderCounter";
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "@calcom/debugging",
|
||||
"description": "Debugging utilities",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "@calcom/tsconfig/react-library.json",
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": [
|
||||
"../../apps/web/next-env.d.ts",
|
||||
"../types/*.d.ts",
|
||||
"../types/next-auth.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
],
|
||||
"exclude": ["dist", "build", "node_modules"]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import React from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
export default function MainLayout({
|
||||
children,
|
||||
...rest
|
||||
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
|
||||
return (
|
||||
<Shell withoutMain={true} {...rest}>
|
||||
{children}
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
|
||||
export const getLayout = (page: React.ReactElement) => <MainLayout>{page}</MainLayout>;
|
||||
@@ -1,51 +0,0 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import React from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { HorizontalTabs } from "@calcom/ui";
|
||||
import type { VerticalTabItemProps, HorizontalTabItemProps } from "@calcom/ui";
|
||||
|
||||
import { FiltersContainer } from "../components/FiltersContainer";
|
||||
|
||||
const tabs: (VerticalTabItemProps | HorizontalTabItemProps)[] = [
|
||||
{
|
||||
name: "upcoming",
|
||||
href: "/bookings/upcoming",
|
||||
},
|
||||
{
|
||||
name: "unconfirmed",
|
||||
href: "/bookings/unconfirmed",
|
||||
},
|
||||
{
|
||||
name: "recurring",
|
||||
href: "/bookings/recurring",
|
||||
},
|
||||
{
|
||||
name: "past",
|
||||
href: "/bookings/past",
|
||||
},
|
||||
{
|
||||
name: "cancelled",
|
||||
href: "/bookings/cancelled",
|
||||
},
|
||||
];
|
||||
|
||||
export default function BookingLayout({
|
||||
children,
|
||||
...rest
|
||||
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
|
||||
return (
|
||||
<Shell {...rest} hideHeadingOnMobile>
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-col flex-wrap lg:flex-row">
|
||||
<HorizontalTabs tabs={tabs} />
|
||||
<div className="max-w-full overflow-x-auto xl:ml-auto">
|
||||
<FiltersContainer />
|
||||
</div>
|
||||
</div>
|
||||
<main className="w-full">{children}</main>
|
||||
</div>
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
export const getLayout = (page: React.ReactElement) => <BookingLayout>{page}</BookingLayout>;
|
||||
@@ -3,7 +3,8 @@ import { useRouter } from "next/navigation";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { getLayout } from "@calcom/features/MainLayout";
|
||||
import { ShellMain } from "@calcom/features/shell/Shell";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -49,7 +50,7 @@ function WorkflowsPage() {
|
||||
});
|
||||
|
||||
return (
|
||||
<Shell
|
||||
<ShellMain
|
||||
heading={t("workflows")}
|
||||
title={t("workflows")}
|
||||
subtitle={t("workflows_to_automate_notifications")}
|
||||
@@ -92,7 +93,7 @@ function WorkflowsPage() {
|
||||
</FilterResults>
|
||||
</>
|
||||
</LicenseRequired>
|
||||
</Shell>
|
||||
</ShellMain>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -221,4 +222,6 @@ const Filter = (props: {
|
||||
);
|
||||
};
|
||||
|
||||
WorkflowsPage.getLayout = getLayout;
|
||||
|
||||
export default WorkflowsPage;
|
||||
Reference in new issue
Block a user