rsnext/examples/with-fingerprintjs-pro/components/CacheStrategySelector.tsx
Ilya Taratukhin a4117c94b0
Adding example with-fingerprintjs-pro for identifying visitors (#37549)
## 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/
2022-06-22 11:48:22 +00:00

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>
)
}