check if index of category is out of range by LukasBoll · Pull Request #2121 · eclipsesource/jsonforms
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.
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.
| </AppBar> | ||
| <div style={{ marginTop: '0.5em' }}> | ||
| <MaterialLayoutRenderer {...childProps} /> | ||
| <MaterialLayoutRenderer {...childProps} key={safeCategory} /> |
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.
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.
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
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
| </AppBar> | ||
| <div style={{ marginTop: '0.5em' }}> | ||
| <MaterialLayoutRenderer {...childProps} /> | ||
| <MaterialLayoutRenderer {...childProps} key={safeCategory} /> |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters