-
-
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
Filters - Cannot read properties of null (reading 'control') #7749
Comments
I don't know what you're trying to achieve with the JSX you passed as custom actions, but with this code the error is normal. The cations component must contain a FilterForm if you add a FilterButton, as explained in https://marmelab.com/react-admin/FilteringTutorial.html#using-the-custom-filters-in-the-list-actions |
@fzaninotto I've followed all the documentation explicitly and tried all the possible cases, including the one you suggested, and no it's not working, that's basically why I created an Issue to get more insights about a potential bug. A similar topic was mentioned here #7501. I think there's a problem with the More Info (as labeled)I need to customize the actions because I need to omit the default Tried usecases:
<List filters={[<TextInput variant="outlined" placeholder="Example" label="City" source="city" />]} /> Result - did not work, also shows the
<Form>
<List filters={[<TextInput variant="outlined" placeholder="Example" label="City" source="city"
/>]} />
</Form> Result - did not show the error message, but it was not filtering properly
<SimpleForm>
<List filters={[<TextInput variant="outlined" placeholder="Example" label="City" source="city"
/>]} />
</SimpleForm> Result - did not work, also shows the In conclusion, I tried a lot of use cases and it was not just reading the context properly, I even tried creating my own form to wrap the Also, I suspect that it might an issue from my setup but I am curious how is that possible, I have all the correct dependencies installed. NB:I am using Yarn PnP. (updated the issue description) |
Ticket UpdateThe issue is with PnP. I changed my FromyarnPath: .yarn/releases/yarn-3.2.0.cjs
packageExtensions:
"@mui/styled-engine@*":
dependencies:
"@emotion/react": "*"
"@emotion/styled": "*"
"@mui/x-date-pickers@*":
dependencies:
"@babel/runtime": "*"
ra-core@*:
dependencies:
connected-react-router: "*"
history: <5
ra-ui-materialui@*:
dependencies:
react-hook-form: "*"
react-admin@*:
dependencies:
prop-types: "*"
"@types/prop-types": "*"
peerDependencies:
"@types/react-router-dom": "*"
ToyarnPath: .yarn/releases/yarn-3.2.0.cjs
packageExtensions:
# "@mui/styled-engine@*":
# dependencies:
# "@emotion/react": "*"
# "@emotion/styled": "*"
# "@mui/x-date-pickers@*":
# dependencies:
# "@babel/runtime": "*"
# ra-core@*:
# dependencies:
# connected-react-router: "*"
# history: <5
# ra-ui-materialui@*:
# dependencies:
# react-hook-form: "*"
# react-admin@*:
# dependencies:
# prop-types: "*"
# "@types/prop-types": "*"
# peerDependencies:
# "@types/react-router-dom": "*"
nodeLinker: node-modules And it worked as expected. Any idea if my |
Indeed, we did not test it with PnP |
@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?
|
Thanks for the investigation and the detailed report. I'm OK with your first suggestion. Would you like to open a PR for it? |
I have the same issue, but using |
So for me the issue was not related to
Then a commit removed the |
@andrecastelo This solved the problem for me! <3 |
Hi! After upgrading to version 5, this problem showed up. I'm using yarn. I noticed that in my yarn-lock file there are two different versions of react-hook-form, react-hook-form "^7.52.0" for react-admin version 5.0.0 and react-hook-form "^7.43.9" for react-admin version ^4.9.0. |
This usually means you have multiple versions of react-hook-form installed. Check your lock files and merge duplicates manually |
Yes, react-admin 5.0.0 installs two versions. I solved it by adding react-hook-form as peer dependency in my package.json file:
|
What you were expecting:
Normal filtering for the list
What happened instead:

Steps to reproduce:
<List />
to contain somefilters
Related code:
Environment
4.1.0
3.x
18.1.0
Chrome
NB
Using yarn PnP for this project which might be something related to the issue.
The text was updated successfully, but these errors were encountered: