Skip to content

Commit 5280e5a

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/dynamic-uischema-array-items
2 parents 96bdcf4 + f6bcf5f commit 5280e5a

22 files changed

+724
-87
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ it according to semantic versioning. For example, if your PR adds a breaking cha
1515
should change the heading of the (upcoming) version to include a major version bump.
1616
1717
-->
18+
# 6.0.0-beta.13
19+
20+
## @rjsf/shadcn
21+
22+
- Updated `lodash` import in `fancy-multi-select.tsx` to to be direct import, fixing [#4696](https://github.com/rjsf-team/react-jsonschema-form/issues/4696)
23+
24+
# 6.0.0-beta.13
25+
26+
## @rjsf/core
27+
28+
- Added `experimental_componentUpdateStrategy` prop to `Form` component to control re-render optimization behavior. Supports `'customDeep'` (default, uses deep equality checks that ignore functions), `'shallow'`, and `'always'`
29+
30+
## @rjsf/utils
31+
32+
- Extended `Registry` interface to include optional `experimental_componentUpdateStrategy` property
33+
- Added `shallowEquals()` utility function for shallow equality comparisons
34+
35+
# 6.0.0-beta.13
36+
37+
## rjsf/utils
38+
39+
- Always make all references absolute in nested bundled schemas
1840

1941
# 6.0.0-beta.12
2042

packages/core/src/components/Form.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,20 @@ export interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
195195
* `emptyObjectFields`
196196
*/
197197
experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;
198+
/**
199+
* Controls the component update strategy used by the Form's `shouldComponentUpdate` lifecycle method.
200+
*
201+
* - `'customDeep'`: Uses RJSF's custom deep equality checks via the `deepEquals` utility function,
202+
* which treats all functions as equivalent and provides optimized performance for form data comparisons.
203+
* - `'shallow'`: Uses shallow comparison of props and state (only compares direct properties). This matches React's PureComponent behavior.
204+
* - `'always'`: Always rerenders when called. This matches React's Component behavior.
205+
*
206+
* @default 'customDeep'
207+
*/
208+
experimental_componentUpdateStrategy?: 'customDeep' | 'shallow' | 'always';
198209
/** Optional function that allows for custom merging of `allOf` schemas
199210
*/
211+
200212
experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;
201213
// Private
202214
/**
@@ -514,9 +526,9 @@ export default class Form<
514526
* @returns - True if the component should be updated, false otherwise
515527
*/
516528
shouldComponentUpdate(nextProps: FormProps<T, S, F>, nextState: FormState<T, S, F>): boolean {
517-
return shouldRender(this, nextProps, nextState);
529+
const { experimental_componentUpdateStrategy = 'customDeep' } = this.props;
530+
return shouldRender(this, nextProps, nextState, experimental_componentUpdateStrategy);
518531
}
519-
520532
/** Gets the previously raised customValidate errors.
521533
*
522534
* @returns the previous customValidate errors
@@ -869,7 +881,11 @@ export default class Form<
869881

870882
/** Returns the registry for the form */
871883
getRegistry(): Registry<T, S, F> {
872-
const { translateString: customTranslateString, uiSchema = {} } = this.props;
884+
const {
885+
translateString: customTranslateString,
886+
uiSchema = {},
887+
experimental_componentUpdateStrategy = 'customDeep',
888+
} = this.props;
873889
const { schema, schemaUtils } = this.state;
874890
const { fields, templates, widgets, formContext, translateString } = getDefaultRegistry<T, S, F>();
875891
return {
@@ -888,6 +904,7 @@ export default class Form<
888904
schemaUtils,
889905
translateString: customTranslateString || translateString,
890906
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY],
907+
experimental_componentUpdateStrategy,
891908
};
892909
}
893910

packages/core/src/components/fields/SchemaField.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useCallback, Component, ComponentType } from 'react';
22
import {
33
ADDITIONAL_PROPERTY_FLAG,
4-
deepEquals,
54
descriptionId,
65
ErrorSchema,
76
FieldProps,
@@ -15,6 +14,7 @@ import {
1514
mergeObjects,
1615
Registry,
1716
RJSFSchema,
17+
shouldRender,
1818
StrictRJSFSchema,
1919
TranslatableString,
2020
UI_OPTIONS_KEY,
@@ -343,7 +343,9 @@ class SchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
343343
FieldProps<T, S, F>
344344
> {
345345
shouldComponentUpdate(nextProps: Readonly<FieldProps<T, S, F>>) {
346-
return !deepEquals(this.props, nextProps);
346+
const { experimental_componentUpdateStrategy = 'customDeep' } = this.props.registry;
347+
348+
return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
347349
}
348350

349351
render() {

packages/core/test/SchemaField.test.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('SchemaField', () => {
5252
schemaUtils,
5353
translateString: englishStringTranslator,
5454
globalUiOptions: undefined,
55+
experimental_componentUpdateStrategy: 'customDeep',
5556
});
5657
});
5758
it('should provide expected registry with globalUiOptions as prop', () => {
@@ -86,6 +87,7 @@ describe('SchemaField', () => {
8687
schemaUtils,
8788
translateString: englishStringTranslator,
8889
globalUiOptions: { copyable: true },
90+
experimental_componentUpdateStrategy: 'customDeep',
8991
});
9092
});
9193
});

0 commit comments

Comments
 (0)