Skip to content
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

Fix <SimpleList> throws an error when no data in standalone mode #10313

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Oct 29, 2024

Problem

Since #10184, published in 5.2.0, <SimpleList> and <Datagrid> throw an error when used in standalone mode (i.e., outside of a ListContext) with an empty data.

useListContext must be used inside a ListContextProvider

Solution

The problem comes from ListNoResults, which reads the ListContext to determine if there is an active filter.

const { filterValues, setFilters } = useListContext();

Solution

Use the alternative useListContextWithProps instead of useListContext.

## Problem

Since #10184, published in 5.2.0, `<SimpleList>` and `<Datagrid>` throw an error when used in standalone mode (i.e., outside of a ListContext) with an empty `data`.

## Solution

The problem comes from `ListNoResults`, which reads the `ListContext` to determine if there is an active filter.

## Solution

Use the alternative `useListContextWithProps` instead of `useListContext`.
@slax57 slax57 added this to the 5.3.2 milestone Oct 29, 2024
@slax57 slax57 merged commit 2f22f09 into master Oct 29, 2024
15 checks passed
@slax57 slax57 deleted the fix-standalone-list branch October 29, 2024 09:24
Copy link
Contributor

@erwanMarmelab erwanMarmelab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants