-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add WithListContext component #8917
Conversation
|
||
## `render` | ||
|
||
A function which will be called with the current [`ListContext`](./useListContext.md) as argument. It should return a React element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function which will be called with the current [`ListContext`](./useListContext.md) as argument. It should return a React element. | |
A function which will be called with the current [`ListContext`](./useListContext.md) as argument. It should return a React node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's a React Element.
docs/WithListContext.md
Outdated
|
||
Whenever you use a react-admin component fetching a list of records, react-admin stores it in a [`ListContext`](./useListContext.md). This means that `<WithListContext>` works out of the box: | ||
|
||
- in descendants of the [`<List>`](./ListBase.md), [`<InfiniteList>`](./InfiniteList.md), and [`<ListBase>`](./ListBase.md) components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- in descendants of the [`<List>`](./ListBase.md), [`<InfiniteList>`](./InfiniteList.md), and [`<ListBase>`](./ListBase.md) components | |
- as a child of the [`<List>`](./ListBase.md), [`<InfiniteList>`](./InfiniteList.md), and [`<ListBase>`](./ListBase.md) components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the existing sentence confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion leads to another confusion: that the component would only work when used as child and not as grandchild.
I think that "descendants" is the right term.
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
Problem
Reading data from a
ListContext
requires creating another component, as it's only available via a hook.Solution
A render prop version of
useListContext
calledWithListContext
This also facilitates the use of charts in react-admin: