Skip to content

Instantly share code, notes, and snippets.

View danielnass's full-sized avatar
🚀
Ship it!

Daniel Nass danielnass

🚀
Ship it!
View GitHub Profile
@bryanprimus
bryanprimus / viewModelZustand.tsx
Last active November 4, 2024 01:41
ViewModelProvider with zustand and react context
import { createContext, useContext, useRef } from 'react'
import { Button, Text } from 'tamagui'
import { createStore, useStore, type StateCreator, type StoreApi } from 'zustand'
const ViewModelContext = createContext<StoreApi<any> | null>(null)
const ViewModelProvider = <T,>({
children,
initializer,
}: React.PropsWithChildren<{ initializer: StateCreator<T> }>) => {