-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(@clayui/core): Add Collection implementation #5013
Conversation
ca1d545
to
d49f870
Compare
I've pushed some more resources, adding support for asynchronous paginated data loading to the const {loadMore, resource} = useResource({
fetch: async (link: string) => {
const result = await fetch(link);
const json = await result.json();
return {
cursor: json.info.next,
items: json.results,
};
},
link: 'https://rickandmortyapi.com/api/character',
variables: {limit: 10},
}); Extends the This covers a part of the RFC for asynchronous loading to list, this doesn't work well for tree because to deal with tree we need to do more complex logic, so it's quite likely that in another issue I'll be creating a hook that extends from |
I sent one more commit with an integration with There are still some things to be worked on in the integration, we need to refactor the cache implementation to better handle the data control, we need to make something like a client that can handle promises, cursors and the cache, since we are integrating with Suspense , when there is a promise in progress it loses data that is in some state or To use the integration is optional, this allows people to adopt it gradually otherwise we could cause a lot of breaking change, once it is enabled it is necessary for people to use it correctly with const {resource} = useResource({
link: 'https://rickandmortyapi.com/api/character',
suspense: true,
variables: {limit: 10},
}); There is also a behavior that I added in the RFC that needs a review in the ErrorBoundary session, an idea I had in mind is that calling |
02e5600
to
67007c4
Compare
Well, I'm back again for this PR, sent a few more changes to refactor the cache implementation to work better with the Suspense and ErrorBoundary integration, it got simpler but we also need the I made some minimal fixes, for example when the I will do some more tests and add more tests to cover the new features of |
492faaa
to
84114a8
Compare
I sent a few more changes to add testing to the To finalize the implementation of Collection, we need to add tree support, I created an issue to handle this #5030. I will also create an issue to review the RFC that comments on the integration with ErrorBoundary. I'm going to create another issue as umbrella to add the list of components that we will be adding to the Collection with pattern. |
… ErrorBoundary This commit adds the initial integration with React.Suspense for data fetching. This is not a final integration because we need to refactor the cache implementation to be global and move the data from PROMISES and CURSORS to a global instance to simplify the implementation, we are using PROMISES as a data source to retrieve the values in some moments. Since is integrated with Suspense and there is a promise in progress the component loses any state value or something that is with `useRef`, so we need to move the cache to work global.
…nse and ErrorBoundary and improves the integration with the cache system and avoids redundancy
… table and the style
…h Suspense and use Infinite loading with cursor usage in the documentation
…enerate the API table for the useResource hook
84114a8
to
368c870
Compare
I'm going ahead and merging this PR! |
Closes #5009
RFC 0004 Collection component
This PR mainly implements the virtualization pattern for the collection, there are some challenges that virtualization may not work very well in more complex cases in DropDown for example, also to create virtualization for Tree, we will have to deal with something like react-vtree does so I'll be working on it in another issue.
This is still a draft so other people can see and discuss something about if they find any improvements, we still need to add the
cursor
feature touseResource
so that we can integrate asynchronous loading with the Collection.ToDo
useResource
hook documentationuseResource
hook with Suspense and ErrorBoundaryuseResource
hook<Provider />
inuseResource
hook