-
Notifications
You must be signed in to change notification settings - Fork 373
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
check if index of category is out of range #2121
check if index of category is out of range #2121
Conversation
✅ Deploy Preview for jsonforms-examples ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
Thanks for the PR :) I added a comment on avoiding introducing a useEffect
and added a question.
packages/material-renderers/src/layouts/MaterialCategorizationLayout.tsx
Outdated
Show resolved
Hide resolved
packages/material-renderers/src/layouts/MaterialCategorizationLayout.tsx
Show resolved
Hide resolved
e163756
to
d35500b
Compare
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.
Thanks for the update. The example works well. I added a minor fix suggestion for the new file and added a question.
{categories.map((_, idx: number) => ( | ||
<Tab key={idx} label={tabLabels[idx]} /> | ||
))} | ||
</Tabs> | ||
</AppBar> | ||
<div style={{ marginTop: '0.5em' }}> | ||
<MaterialLayoutRenderer {...childProps} /> | ||
<MaterialLayoutRenderer {...childProps} key={safeCategory} /> |
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.
What is the reason for adding this key
? I don't think we need it.
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 think it always makes sense to set a new key and reset the state of all components, as we are working on different data once we change the tap. Also, we could run into similar issues with e.g. the detail list or expandable list, where the old state might not fit to the new data and the selected element is out of range.
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 feel it is not strictly necessary because the childProps should change anyway. But we can leave it in as it shouldn't hurt either :D
d35500b
to
7a07554
Compare
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.
Thanks for the update, LGTM
{categories.map((_, idx: number) => ( | ||
<Tab key={idx} label={tabLabels[idx]} /> | ||
))} | ||
</Tabs> | ||
</AppBar> | ||
<div style={{ marginTop: '0.5em' }}> | ||
<MaterialLayoutRenderer {...childProps} /> | ||
<MaterialLayoutRenderer {...childProps} key={safeCategory} /> |
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 feel it is not strictly necessary because the childProps should change anyway. But we can leave it in as it shouldn't hurt either :D
closes #2111