Files
StevenandGitHub 4466ba436b chore(examples): use default prettier for examples/templates (#60530)
## 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
2024-01-11 16:01:44 -07:00

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;