UploadProvider
WIPShare an upload store across the component tree via React context.
UploadProvider publishes an upload store on React context so any descendant can reach it with
useUploader, useUploaderActions, or useUploadStore — no prop drilling.
Usage
Create the store once, outside render, and pass it in:
import { UploadProvider } from '@gentleduck/upload/react'
import { store } from './upload'
export function App() {
return (
<UploadProvider store={store}>
<Routes />
</UploadProvider>
)
}
Props
UploadProviderProps<M, C, P, R>:
| Prop | Type | Description |
|---|---|---|
store | Store.UploadStore<M, C, P, R> | The store from createUploadStore |
children | ReactNode | Subtree that can access the store via hooks |
Related hooks
useUploadStore()— returns the raw store from context, or throws if used outside a provider.isUploadStore(value)— a runtime type guard that checks a value has the store shape (getSnapshot,subscribe,dispatch,on,off,waitFor).
Notes
- One provider per tree is enough. For truly independent pipelines (different backends or
persistence keys), create separate stores and nest providers, or skip the provider and pass a
store directly to
useUploader(store). - Create the store in a module (or a stable ref), never inline in render, so it isn't recreated on every render.
- All
useUploader/useUploaderActionscalls must be inside a descendant of the provider — unless you pass a store touseUploaderexplicitly.