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

Improve performance #1655

Merged
merged 4 commits into from
Nov 18, 2020
Merged

Conversation

AlexandraBuzila
Copy link
Member

Avoid unnecessary initialization calls in React

Use the initialization function of 'useReducer' to avoid unnecessary dispatching of init actions whose result is ignored anyway.

Make sure validation is run on set schema

Only update state with changed properties of JsonFormsCore

Instead of calling the INIT action when one of the core properties changes, introduce a new action (UPDATE_CORE) which updates only the changed properties in the state.

@coveralls
Copy link

coveralls commented Oct 30, 2020

Coverage Status

Coverage increased (+0.05%) to 88.434% when pulling f289fe3 on AlexandraBuzila:improve-performance into d97a584 on eclipsesource:master.

@sdirix sdirix force-pushed the improve-performance branch 4 times, most recently from 5b9ee56 to 7c92418 Compare November 12, 2020 14:56
@AlexandraBuzila AlexandraBuzila force-pushed the improve-performance branch 2 times, most recently from 0ac4221 to d582521 Compare November 13, 2020 17:21
@AlexandraBuzila AlexandraBuzila marked this pull request as ready for review November 13, 2020 17:21
@sdirix sdirix force-pushed the improve-performance branch 2 times, most recently from e59adb2 to 5c870ea Compare November 18, 2020 09:37
AlexandraBuzila and others added 4 commits November 18, 2020 15:18
Adds a new action (UPDATE_CORE) which updates the state only
when there are actual changes. This action is now used in React
to handle incoming props. Therefore changing JsonForms props
behaves much more intuitively. This also allows to use JsonForms
in a 'controlled' style without a performance penalty.
 * Avoid unnecessary initialization calls by initializing reducers
with functions
 * Avoid updating context value when there are no changes
 * Memoize tester evaluations
 * Memoize uischema evaluations
 * Use customized 'areEqual' instead of 'isEqual'
Move onChange handling from JsonFormsDispatch to StateProvider as it
also manages the source of truth, i.e. the JsonForms core containing
the emitted data and errors.

Also use `useEffect` instead of `useLayoutEffect` as the latter one is
not needed here. This also removes warnings when using JsonForms in SSR
settings.
As a new schema is set by the the 'SET_SCHEMA' action the data needs to
be revalidated. This is now done.
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.

LGTM!

@sdirix sdirix merged commit 46376f9 into eclipsesource:master Nov 18, 2020
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