check if index of category is out of range by LukasBoll · Pull Request #2121 · eclipsesource/jsonforms

@LukasBoll

@netlify

@coveralls

Coverage Status

Coverage: 83.193%. Remained the same when pulling d35500b on LukasBoll:categorisationAndSelection into 229d99a on eclipsesource:master.

lucas-koehler

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.

lucas-koehler

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

@LukasBoll

lucas-koehler

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