mirror of
https://github.com/langgenius/dify.git
synced 2026-02-09 23:20:12 -05:00
refactor(i18n): about locales (#30336)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
15
web/utils/server-only-context.ts
Normal file
15
web/utils/server-only-context.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// credit: https://github.com/manvalls/server-only-context/blob/main/src/index.ts
|
||||
|
||||
import { cache } from 'react'
|
||||
|
||||
export default <T>(defaultValue: T): [() => T, (v: T) => void] => {
|
||||
const getRef = cache(() => ({ current: defaultValue }))
|
||||
|
||||
const getValue = (): T => getRef().current
|
||||
|
||||
const setValue = (value: T) => {
|
||||
getRef().current = value
|
||||
}
|
||||
|
||||
return [getValue, setValue]
|
||||
}
|
||||
Reference in New Issue
Block a user