a4117c94b0
## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Deployed on https://with-fingerprintjs-pro.vercel.app/
27 lines
856 B
TypeScript
27 lines
856 B
TypeScript
import { useRouter } from 'next/router'
|
|
|
|
export const CacheStrategySelector = () => {
|
|
const router = useRouter()
|
|
const { asPath, route } = router
|
|
const value = asPath.split('/')[2]
|
|
|
|
return (
|
|
<div className="cache-option-toggler">
|
|
<h4>Cache option</h4>
|
|
<select
|
|
name="cache-option"
|
|
onChange={(event) => {
|
|
const newValue = event.currentTarget.value
|
|
const newRoute = route.replace('[cacheStrategy]', newValue)
|
|
router.push(newRoute, undefined, { scroll: false })
|
|
}}
|
|
value={value}
|
|
>
|
|
<option value="no-cache">Without cache</option>
|
|
<option value="memory-cache">Memory Cache</option>
|
|
<option value="session-storage-cache">Session Storage Cache</option>
|
|
<option value="ls-cache">Local Storage Cache</option>
|
|
</select>
|
|
</div>
|
|
)
|
|
}
|