Skip to content

Commit 0909464

Browse files
committed
Bump version to 2.8.2 and update dist files
1 parent f12f381 commit 0909464

File tree

5 files changed

+185
-116
lines changed

5 files changed

+185
-116
lines changed

dist/react-json-form.cjs

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,27 +2832,36 @@ class OneOfTopLevel extends React__default["default"].Component {
28322832
return schema;
28332833
};
28342834

2835-
this.handleChange = e => {
2836-
this.updateData(this.getSchema(), this.getSchema(e.target.value));
2837-
this.setState({
2838-
option: e.target.value
2839-
});
2835+
this.handleOptionChange = e => {
2836+
this.updateData(this.getSchema(e.target.value)); // Uncomment when caching is reimplemented
2837+
//
2838+
// this.setState({
2839+
// option: e.target.value
2840+
// });
28402841
};
28412842

2842-
this.schemaName = this.props.schemaName || 'oneOf';
2843-
this.state = {
2844-
option: this.findSelectedOption()
2845-
};
2843+
this.schemaName = this.props.schemaName || 'oneOf'; // Uncomment when caching is implemented
2844+
//
2845+
// this.state = {
2846+
// option: this.findSelectedOption(),
2847+
// };
28462848
}
28472849

2848-
updateData(oldSchema, newSchema) {
2849-
getSchemaType(oldSchema);
2850-
getSchemaType(newSchema);
2850+
updateData(newSchema) {
28512851
this.props.args.onChange(this.props.args.name, getBlankData(newSchema, this.props.args.getRef));
28522852
}
28532853

28542854
render() {
2855-
let schema = this.getSchema();
2855+
/* Perfomance note:
2856+
*
2857+
* In order to resolve https://github.com/bhch/react-json-form/issues/67,
2858+
* we will not cache the selected option. Instead, we'll recalculate the
2859+
* selected option on every render.
2860+
*
2861+
* If there're serious performance issues, we'll reconsider caching.
2862+
*/
2863+
let selectedOption = this.findSelectedOption();
2864+
let schema = this.getSchema(selectedOption);
28562865
let type = getSchemaType(schema);
28572866
let args = this.props.args;
28582867
let rowFunc;
@@ -2878,9 +2887,9 @@ class OneOfTopLevel extends React__default["default"].Component {
28782887
}, /*#__PURE__*/React__default["default"].createElement("div", {
28792888
className: "rjf-oneof-selector"
28802889
}, /*#__PURE__*/React__default["default"].createElement(FormSelectInput, {
2881-
value: this.state.option,
2890+
value: selectedOption,
28822891
options: this.getOptions(),
2883-
onChange: this.handleChange,
2892+
onChange: this.handleOptionChange,
28842893
className: "rjf-oneof-selector-input",
28852894
label: selectorLabel
28862895
})), rows);
@@ -3025,30 +3034,35 @@ class OneOf extends React__default["default"].Component {
30253034
return getSchemaType(this.props.parentArgs.schema);
30263035
};
30273036

3028-
this.handleChange = e => {
3029-
this.updateData(this.getSchema(), this.getSchema(e.target.value));
3030-
this.setState({
3031-
option: e.target.value
3032-
});
3037+
this.handleOptionChange = (e, selectedOption) => {
3038+
this.updateData(this.getSchema(selectedOption), this.getSchema(e.target.value)); // Uncomment when caching is implemented
3039+
//
3040+
// this.setState({
3041+
// option: e.target.value
3042+
// });
30333043
};
30343044

3035-
this.schemaName = this.props.schemaName || 'oneOf';
3036-
this.state = {
3037-
option: this.findSelectedOption()
3038-
};
3045+
this.schemaName = this.props.schemaName || 'oneOf'; // Uncomment when caching is implemented
3046+
//
3047+
// this.state = {
3048+
// option: this.findSelectedOption(),
3049+
// };
30393050
}
3040-
3041-
componentDidUpdate(prevProps, prevState) {
3042-
if (prevProps.nextArgs || this.props.nextArgs) {
3043-
let prevDataType = 'string';
3044-
let newDataType = 'string';
3045-
if (prevProps.nextArgs) prevDataType = actualType(prevProps.nextArgs.data);
3046-
if (this.props.nextArgs) newDataType = actualType(this.props.nextArgs.data);
3047-
if (prevDataType !== newDataType) this.setState({
3048-
option: this.findSelectedOption()
3049-
});
3050-
}
3051+
/* Uncomment when caching is implemente
3052+
componentDidUpdate(prevProps, prevState) {
3053+
if (prevProps.nextArgs || this.props.nextArgs) {
3054+
let prevDataType = 'string';
3055+
let newDataType = 'string';
3056+
if (prevProps.nextArgs)
3057+
prevDataType = actualType(prevProps.nextArgs.data);
3058+
if (this.props.nextArgs)
3059+
newDataType = actualType(this.props.nextArgs.data);
3060+
if (prevDataType !== newDataType)
3061+
this.setState({option: this.findSelectedOption()});
3062+
}
30513063
}
3064+
*/
3065+
30523066

30533067
updateData(oldSchema, newSchema) {
30543068
let parentType = this.getParentType();
@@ -3090,7 +3104,16 @@ class OneOf extends React__default["default"].Component {
30903104
}
30913105

30923106
render() {
3093-
let schema = this.getSchema();
3107+
/* Perfomance note:
3108+
*
3109+
* In order to resolve https://github.com/bhch/react-json-form/issues/67,
3110+
* we will not cache the selected option. Instead, we'll recalculate the
3111+
* selected option on every render.
3112+
*
3113+
* If there're serious performance issues, we'll reconsider caching.
3114+
*/
3115+
let selectedOption = this.findSelectedOption();
3116+
let schema = this.getSchema(selectedOption);
30943117
let type = getSchemaType(schema);
30953118
let args = this.props.nextArgs ? this.props.nextArgs : this.props.parentArgs;
30963119
let rowFunc;
@@ -3119,9 +3142,9 @@ class OneOf extends React__default["default"].Component {
31193142
}, /*#__PURE__*/React__default["default"].createElement("div", {
31203143
className: "rjf-oneof-selector"
31213144
}, /*#__PURE__*/React__default["default"].createElement(FormSelectInput, {
3122-
value: this.state.option,
3145+
value: selectedOption,
31233146
options: this.getOptions(),
3124-
onChange: this.handleChange,
3147+
onChange: e => this.handleOptionChange(e, selectedOption),
31253148
className: "rjf-oneof-selector-input",
31263149
label: selectorLabel
31273150
})), rows);

dist/react-json-form.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-json-form.modern.js

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,27 +2826,36 @@ class OneOfTopLevel extends React$1.Component {
28262826
return schema;
28272827
};
28282828

2829-
this.handleChange = e => {
2830-
this.updateData(this.getSchema(), this.getSchema(e.target.value));
2831-
this.setState({
2832-
option: e.target.value
2833-
});
2829+
this.handleOptionChange = e => {
2830+
this.updateData(this.getSchema(e.target.value)); // Uncomment when caching is reimplemented
2831+
//
2832+
// this.setState({
2833+
// option: e.target.value
2834+
// });
28342835
};
28352836

2836-
this.schemaName = this.props.schemaName || 'oneOf';
2837-
this.state = {
2838-
option: this.findSelectedOption()
2839-
};
2837+
this.schemaName = this.props.schemaName || 'oneOf'; // Uncomment when caching is implemented
2838+
//
2839+
// this.state = {
2840+
// option: this.findSelectedOption(),
2841+
// };
28402842
}
28412843

2842-
updateData(oldSchema, newSchema) {
2843-
getSchemaType(oldSchema);
2844-
getSchemaType(newSchema);
2844+
updateData(newSchema) {
28452845
this.props.args.onChange(this.props.args.name, getBlankData(newSchema, this.props.args.getRef));
28462846
}
28472847

28482848
render() {
2849-
let schema = this.getSchema();
2849+
/* Perfomance note:
2850+
*
2851+
* In order to resolve https://github.com/bhch/react-json-form/issues/67,
2852+
* we will not cache the selected option. Instead, we'll recalculate the
2853+
* selected option on every render.
2854+
*
2855+
* If there're serious performance issues, we'll reconsider caching.
2856+
*/
2857+
let selectedOption = this.findSelectedOption();
2858+
let schema = this.getSchema(selectedOption);
28502859
let type = getSchemaType(schema);
28512860
let args = this.props.args;
28522861
let rowFunc;
@@ -2872,9 +2881,9 @@ class OneOfTopLevel extends React$1.Component {
28722881
}, /*#__PURE__*/React$1.createElement("div", {
28732882
className: "rjf-oneof-selector"
28742883
}, /*#__PURE__*/React$1.createElement(FormSelectInput, {
2875-
value: this.state.option,
2884+
value: selectedOption,
28762885
options: this.getOptions(),
2877-
onChange: this.handleChange,
2886+
onChange: this.handleOptionChange,
28782887
className: "rjf-oneof-selector-input",
28792888
label: selectorLabel
28802889
})), rows);
@@ -3019,30 +3028,35 @@ class OneOf extends React$1.Component {
30193028
return getSchemaType(this.props.parentArgs.schema);
30203029
};
30213030

3022-
this.handleChange = e => {
3023-
this.updateData(this.getSchema(), this.getSchema(e.target.value));
3024-
this.setState({
3025-
option: e.target.value
3026-
});
3031+
this.handleOptionChange = (e, selectedOption) => {
3032+
this.updateData(this.getSchema(selectedOption), this.getSchema(e.target.value)); // Uncomment when caching is implemented
3033+
//
3034+
// this.setState({
3035+
// option: e.target.value
3036+
// });
30273037
};
30283038

3029-
this.schemaName = this.props.schemaName || 'oneOf';
3030-
this.state = {
3031-
option: this.findSelectedOption()
3032-
};
3039+
this.schemaName = this.props.schemaName || 'oneOf'; // Uncomment when caching is implemented
3040+
//
3041+
// this.state = {
3042+
// option: this.findSelectedOption(),
3043+
// };
30333044
}
3034-
3035-
componentDidUpdate(prevProps, prevState) {
3036-
if (prevProps.nextArgs || this.props.nextArgs) {
3037-
let prevDataType = 'string';
3038-
let newDataType = 'string';
3039-
if (prevProps.nextArgs) prevDataType = actualType(prevProps.nextArgs.data);
3040-
if (this.props.nextArgs) newDataType = actualType(this.props.nextArgs.data);
3041-
if (prevDataType !== newDataType) this.setState({
3042-
option: this.findSelectedOption()
3043-
});
3044-
}
3045+
/* Uncomment when caching is implemente
3046+
componentDidUpdate(prevProps, prevState) {
3047+
if (prevProps.nextArgs || this.props.nextArgs) {
3048+
let prevDataType = 'string';
3049+
let newDataType = 'string';
3050+
if (prevProps.nextArgs)
3051+
prevDataType = actualType(prevProps.nextArgs.data);
3052+
if (this.props.nextArgs)
3053+
newDataType = actualType(this.props.nextArgs.data);
3054+
if (prevDataType !== newDataType)
3055+
this.setState({option: this.findSelectedOption()});
3056+
}
30453057
}
3058+
*/
3059+
30463060

30473061
updateData(oldSchema, newSchema) {
30483062
let parentType = this.getParentType();
@@ -3084,7 +3098,16 @@ class OneOf extends React$1.Component {
30843098
}
30853099

30863100
render() {
3087-
let schema = this.getSchema();
3101+
/* Perfomance note:
3102+
*
3103+
* In order to resolve https://github.com/bhch/react-json-form/issues/67,
3104+
* we will not cache the selected option. Instead, we'll recalculate the
3105+
* selected option on every render.
3106+
*
3107+
* If there're serious performance issues, we'll reconsider caching.
3108+
*/
3109+
let selectedOption = this.findSelectedOption();
3110+
let schema = this.getSchema(selectedOption);
30883111
let type = getSchemaType(schema);
30893112
let args = this.props.nextArgs ? this.props.nextArgs : this.props.parentArgs;
30903113
let rowFunc;
@@ -3113,9 +3136,9 @@ class OneOf extends React$1.Component {
31133136
}, /*#__PURE__*/React$1.createElement("div", {
31143137
className: "rjf-oneof-selector"
31153138
}, /*#__PURE__*/React$1.createElement(FormSelectInput, {
3116-
value: this.state.option,
3139+
value: selectedOption,
31173140
options: this.getOptions(),
3118-
onChange: this.handleChange,
3141+
onChange: e => this.handleOptionChange(e, selectedOption),
31193142
className: "rjf-oneof-selector-input",
31203143
label: selectorLabel
31213144
})), rows);

0 commit comments

Comments
 (0)