Skip to content

Commit

Permalink
fix: move load back to provider
Browse files Browse the repository at this point in the history
the thing I thought was a timing issue previously was actually just poor dependency management - make tweaks and move back into the provider so this will work for non-hook users
  • Loading branch information
travis committed Jan 24, 2023
1 parent ee3b59d commit e449b3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/react-uploads-list/src/providers/UploadsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const uploadsListContextDefaultValue: UploadsListContextValue = [
loading: false
},
{
next: async () => { },
reload: async () => { }
next: async () => {},
reload: async () => {}
}
]

Expand Down Expand Up @@ -82,6 +82,9 @@ export function UploadsListProvider ({ size, servicePrincipal, connection, child
}
}

// we should reload the page any time the space or agent change
useEffect(() => { void loadPage() }, [space, agent])

return (
<UploadsListContext.Provider value={[state, actions]}>
{children}
Expand All @@ -93,8 +96,5 @@ export function UploadsListProvider ({ size, servicePrincipal, connection, child
* Use the scoped uploads list context state from a parent `UploadsListProvider`.
*/
export function useUploadsList (): UploadsListContextValue {
const ctx = useContext(UploadsListContext)
// automatically load the first page of results
useEffect(() => { ctx[1].next() }, [])
return ctx
return useContext(UploadsListContext)
}

0 comments on commit e449b3d

Please sign in to comment.