mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { useRouter } from "next/router";
|
|
import Head from "next/head";
|
|
import "../styles/globals.css";
|
|
import "../styles/App.css";
|
|
import { InMemoryCache } from "../providers/InMemoryCache";
|
|
import { LocalStorageCache } from "../providers/LocalStorageCache";
|
|
import { WithoutCache } from "../providers/WithoutCache";
|
|
import { SessionStorageCache } from "../providers/SessionStorageCache";
|
|
import { CacheStrategySelector } from "../components/CacheStrategySelector";
|
|
import { Nav } from "../components/Nav";
|
|
import type { AppProps } from "next/app";
|
|
import type { CacheStrategyPath, RouterProps } from "../components/types";
|
|
|
|
const getFingerprintJsProProviderByCacheStrategy = (
|
|
cacheStrategy: CacheStrategyPath,
|
|
) => {
|
|
switch (cacheStrategy) {
|
|
case "no-cache":
|
|
return WithoutCache;
|
|
case "ls-cache":
|
|
return LocalStorageCache;
|
|
case "session-storage-cache":
|
|
return SessionStorageCache;
|
|
default:
|
|
return InMemoryCache;
|
|
}
|
|
};
|
|
|
|
function MyApp({ Component, pageProps }: AppProps) {
|
|
const router = useRouter();
|
|
const { cacheStrategy } = router.query as RouterProps;
|
|
|
|
const ConfiguredFingerprintJsProProvider =
|
|
getFingerprintJsProProviderByCacheStrategy(cacheStrategy);
|
|
|
|
return (
|
|
<div className="layout">
|
|
<Head>
|
|
<title>FingerprintJs Pro example for Next.js</title>
|
|
</Head>
|
|
<CacheStrategySelector />
|
|
<main>
|
|
<ConfiguredFingerprintJsProProvider>
|
|
<Nav />
|
|
<Component {...pageProps} />
|
|
</ConfiguredFingerprintJsProProvider>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default MyApp;
|