mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Switch the base framework from Create React App to Next.JS
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
a979b6ffdd
commit
77a60c6c48
361 changed files with 5130 additions and 9605 deletions
17
src/hooks/common/use-single-string-url-parameter.ts
Normal file
17
src/hooks/common/use-single-string-url-parameter.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useRouter } from 'next/router'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
export const useSingleStringUrlParameter = <T>(parameter: string, fallback: T): string | T => {
|
||||
const router = useRouter()
|
||||
|
||||
return useMemo(() => {
|
||||
const value = router.query[parameter]
|
||||
return (typeof value === 'string' ? value : value?.[0]) ?? fallback
|
||||
}, [fallback, parameter, router.query])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue