mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
Update Next.js guide to have explicitly nullable useRef type argument (#3053)
* Update nextjs.md with nullable `storeRef` * Update other example in nextjs.md * Apply suggestions from code review --------- Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
This commit is contained in:
parent
3089fdc435
commit
90f8d592d4
@ -124,8 +124,8 @@ export interface CounterStoreProviderProps {
|
||||
export const CounterStoreProvider = ({
|
||||
children,
|
||||
}: CounterStoreProviderProps) => {
|
||||
const storeRef = useRef<CounterStoreApi>(null)
|
||||
if (!storeRef.current) {
|
||||
const storeRef = useRef<CounterStoreApi | null>(null)
|
||||
if (storeRef.current === null) {
|
||||
storeRef.current = createCounterStore()
|
||||
}
|
||||
|
||||
@ -217,8 +217,8 @@ export interface CounterStoreProviderProps {
|
||||
export const CounterStoreProvider = ({
|
||||
children,
|
||||
}: CounterStoreProviderProps) => {
|
||||
const storeRef = useRef<CounterStoreApi>(null)
|
||||
if (!storeRef.current) {
|
||||
const storeRef = useRef<CounterStoreApi | null>(null)
|
||||
if (storeRef.current === null) {
|
||||
storeRef.current = createCounterStore(initCounterStore())
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user