refactor(i18n): about locales (#30336)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-30 14:38:23 +08:00
committed by GitHub
parent 3505516e8e
commit 2399d00d86
70 changed files with 273 additions and 320 deletions

View 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]
}