Filters - Cannot read properties of null (reading 'control')
See original GitHub issueWhat you were expecting:
Normal filtering for the list
What happened instead:
Steps to reproduce:
- Add a resource
- Access the list for this resource
- Modify the
<List />
to contain somefilters
Related code:
const postFilters = [
<TextInput variant="outlined" label="City" source="city" />,
];
<List
filters={postFilters}
actions={
<TopToolbar>
<FilterButton />
</TopToolbar>
}
sort={{ field: 'created_at', order: 'DESC' }}>
{...}
</List>
Environment
- React-admin version:
4.1.0
- Last version that did not exhibit the issue (if applicable):
3.x
- React version:
18.1.0
- Browser:
Chrome
NB
Using yarn PnP for this project which might be something related to the issue.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Cannot read properties of null (reading '_rawValidators')
The array does not render correctly. Here is a picture of how it initially loads. Tabbing through the controls seems to make it...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >cannot read properties of undefined (reading 'filter') in react js
However, When I search for users using the search box, I get a TypeError: Cannot read property 'filter' of undefined The page initially...
Read more >Solved: TypeError Cannot read properties of null (reading
Solved! Go to Solution. ... Hello @RafaelCelaya,. If you are applying a filter to a field in a repeat we have an issue...
Read more >TypeError: Cannot read property 'filter' of Null in JS | bobbyhadz
The "Cannot read property 'filter' of null" error occurs when calling the filter() method on a null value. To solve the error, initialize...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@yousseftarekkh and I investigated the issue further and found the culprit. For anyone else using yarn pnp and having this problem, here is the solution:
We had different versions of react-hook-form installed in the same project, which under pnp leads to problems with the react context not working. (The Provider and Context must be from the same version or the context will be empty.)
After making sure that all versions are exactly the same, it worked. Specifically we fixed the missing dependency of ra-ui-materialui to react-hook-form in the .yarnrc.yml like this:
This way it is using the version from react-admin.
Also we made sure that in our project we are using the same version of react-hook-form as the one that react-admin installs. Now they are in sync and everything works again:
So what can react-admin do to help people that use yarn pnp?
Indeed, we did not test it with PnP