Skip to content

Commit

Permalink
feat: allow users to set page size in W3APIProvider (#308)
Browse files Browse the repository at this point in the history
Allow users to set page size in W3APIProvider.

It feels like it would be cleaner to make it possible to set page size
in the `useUploadsList` hook, but a bit of work on that revealed some
complexity that will take a bit more planning and design to get right -
see
e50e025
for the work I did toward this and a short description of the issues I
ran into.

For now I think this is good enough to ship, and I'd like to think more
carefully about how we handle state in the UploadsList in future
versions of these libs.
  • Loading branch information
travis authored Feb 1, 2023
1 parent e0de2cc commit 814a293
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/react/w3console/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function Logo (): JSX.Element {

export function App (): JSX.Element {
return (
<W3APIProvider>
<W3APIProvider uploadsListPageSize={20}>
<Authenticator>
<div className='flex min-h-full w-full'>
<nav className='flex-none w-64 bg-gray-900 text-white px-4 pb-4 border-r border-gray-800'>
Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/providers/W3API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ export interface UploaderProviderProps extends ServiceConfig {
children?: JSX.Element
}

export function W3APIProvider ({ children }: { children: JSX.Element | JSX.Element[] }): JSX.Element {
export interface W3APIProviderProps {
children: JSX.Element | JSX.Element[]
uploadsListPageSize?: number
}

export function W3APIProvider ({ children, uploadsListPageSize }: W3APIProviderProps): JSX.Element {
return (
<KeyringProvider>
<UploaderProvider>
<UploadsListProvider>
<UploadsListProvider size={uploadsListPageSize}>
<>{children}</>
</UploadsListProvider>
</UploaderProvider>
Expand Down

0 comments on commit 814a293

Please sign in to comment.