Skip to content

Conversation

@LukasBoll
Copy link
Contributor

closes #214

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

Comment on lines 123 to 124
Like most React components, JSON Forms will revalidate and rerender whenever a new object is passed to it.
To reduce unnecessary rerenders and optimize your application's performance, any prop handed over to JsonForms in React should be either stable or memoized.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should elaborate a bit here:

  • JSON Forms uses React.memo, so to avoid any unnecessary rerenderings only stable properties should be handed over

Some specifics:

  • Handing over a new schema prop will revalidate and rerender
  • Handing over a new data prop will revalidate and rerender, except for if it's the data which was emitted by onChange
  • Handing over a new onChange is fine as neither rerender nor revalidate will be triggers
  • Handing over a new i18n is fine, as long as the properties are stable.
  • validationMode change might trigger a revalidation and rerender
  • Handing over anything else new will potentially lead to a rerender.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

closes eclipsesource#214

Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
@sdirix sdirix merged commit 97721f5 into eclipsesource:master Mar 20, 2024
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.

Explain data prop behavior in JSON Forms React

2 participants