Skip to content

Commit 78a7509

Browse files
committed
feat: add support for async setup functions
1 parent 35c29d4 commit 78a7509

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/DittoProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface DittoProviderProps {
2020
*
2121
* Returns a single Ditto instance or an array of instances.
2222
*/
23-
setup: () => Ditto | Ditto[]
23+
setup: () => Ditto | Ditto[] | Promise<Ditto | Ditto[]>
2424
render?: RenderFunction
2525
children?: RenderFunction
2626
}
@@ -65,7 +65,7 @@ export const DittoProvider: React.FunctionComponent<DittoProviderProps> = (
6565
hasMountEffectStarted.current = true
6666
try {
6767
await init(props.initOptions)
68-
const setupReturnValue: Ditto | Ditto[] = props.setup()
68+
const setupReturnValue: Ditto | Ditto[] = await props.setup()
6969
if (Array.isArray(setupReturnValue)) {
7070
const dittoHash: DittoHash = {}
7171
const dittos: Ditto[] = setupReturnValue

0 commit comments

Comments
 (0)