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 incorrect react syntax inside MUI ArrayFieldTemplate (broken hook order) #2912

Closed
wants to merge 1 commit into from

Conversation

cerpins
Copy link

@cerpins cerpins commented Jul 8, 2022

Reasons for making this change

Misuse of functional react is causing following console error in my application (which I'm trying to avoid).
image
After investigation, I notice that DefaultArrayItem is invoked as a function, not as a JSX.Element. Inside of DefaultArrayItem a hook is called, and since the component is called conditionally (as callback to .map) and not as an JSX.Element but a function, this plays out as broken hook order.

If this is related to existing tickets, include links to them as well. Use the syntax fixes #[issue number] (ex: fixes #123).
Could not find if this is related to any existing tickets

Please double check PR and let me know how I can get this merged, thanks.

Checklist

  • I'm adding or updating code
    • Fix error by invoking local component as a JSX component, instead of function
    • Pass key to JSX component so that there is no console.error about not using key

@cerpins cerpins changed the title Fix incorrect react syntax (broken hook order) Fix incorrect react syntax inside MUI ArrayFieldTemplate (broken hook order) Jul 8, 2022
@ecarl65 ecarl65 mentioned this pull request Jul 20, 2022
4 tasks
@heath-freenome
Copy link
Member

While this is a good fix, in August we will be releasing rjsf v5 beta that removes the entire hook issue entirely. Unfortunately this will be a breaking release. How seriously is this causing issues for you?

@cerpins
Copy link
Author

cerpins commented Jul 22, 2022

While this is a good fix, in August we will be releasing rjsf v5 beta that removes the entire hook issue entirely. Unfortunately this will be a breaking release. How seriously is this causing issues for you?

Thanks for the reply. It's mildly bothersome, but nothing urgent that I couldn't wait on. Primary issue is that I don't want my test suite polluted with library errors, since I have tests configured to fail on (unexpected) console errors. As long as you are working on it one way or another, I am happy :)

Edit:
I guess an additional concern for me would be - how breaking is this upcoming change exactly?

@heath-freenome
Copy link
Member

heath-freenome commented Aug 29, 2022

This was fixed by removing hooks entirely from the @rjsf/material-ui and new @rjsf/mui themes. Please see the 5.x migration guide for details

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

Successfully merging this pull request may close these issues.

3 participants