@@ -4972,208 +4972,4 @@ describe('Form omitExtraData and liveOmit', () => {
4972
4972
expect ( errors ) . to . have . lengthOf ( 0 ) ;
4973
4973
} ) ;
4974
4974
} ) ;
4975
-
4976
- describe ( 'experimental_componentUpdateStrategy re-render behavior' , ( ) => {
4977
- let renderCount ;
4978
- let TestField ;
4979
-
4980
- beforeEach ( ( ) => {
4981
- renderCount = 0 ;
4982
-
4983
- // Create a custom field that tracks renders
4984
- TestField = class extends React . Component {
4985
- render ( ) {
4986
- renderCount ++ ;
4987
- return < input type = 'text' value = { this . props . formData || '' } readOnly /> ;
4988
- }
4989
- } ;
4990
- } ) ;
4991
-
4992
- it ( 'should prevent unnecessary re-renders with customDeep strategy when data unchanged' , ( ) => {
4993
- const schema = {
4994
- type : 'object' ,
4995
- properties : {
4996
- name : { type : 'string' } ,
4997
- } ,
4998
- } ;
4999
-
5000
- const formData = { name : 'test' } ;
5001
-
5002
- const { rerender } = createFormComponent ( {
5003
- schema,
5004
- formData,
5005
- experimental_componentUpdateStrategy : 'customDeep' ,
5006
- fields : { StringField : TestField } ,
5007
- } ) ;
5008
-
5009
- const initialRenderCount = renderCount ;
5010
-
5011
- // Re-render with same data - should not cause field re-render with customDeep
5012
- rerender ( {
5013
- schema,
5014
- formData,
5015
- experimental_componentUpdateStrategy : 'customDeep' ,
5016
- fields : { StringField : TestField } ,
5017
- } ) ;
5018
-
5019
- // With customDeep strategy, render count should remain the same for identical data
5020
- expect ( renderCount ) . to . equal ( initialRenderCount ) ;
5021
- } ) ;
5022
-
5023
- it ( 'should allow re-renders with default strategy even when data unchanged' , ( ) => {
5024
- const schema = {
5025
- type : 'object' ,
5026
- properties : {
5027
- name : { type : 'string' } ,
5028
- } ,
5029
- } ;
5030
-
5031
- const formData = { name : 'test' } ;
5032
-
5033
- const { rerender } = createFormComponent ( {
5034
- schema,
5035
- formData,
5036
- experimental_componentUpdateStrategy : 'default' ,
5037
- fields : { StringField : TestField } ,
5038
- } ) ;
5039
-
5040
- const initialRenderCount = renderCount ;
5041
-
5042
- // Re-render with same data - should cause field re-render with default strategy
5043
- rerender ( {
5044
- schema,
5045
- formData,
5046
- experimental_componentUpdateStrategy : 'default' ,
5047
- fields : { StringField : TestField } ,
5048
- } ) ;
5049
-
5050
- // With default strategy, render count should increase even for identical data
5051
- expect ( renderCount ) . to . be . greaterThan ( initialRenderCount ) ;
5052
- } ) ;
5053
-
5054
- it ( 'should re-render with customDeep strategy when data actually changes' , ( ) => {
5055
- const schema = {
5056
- type : 'object' ,
5057
- properties : {
5058
- name : { type : 'string' } ,
5059
- } ,
5060
- } ;
5061
-
5062
- const initialFormData = { name : 'test' } ;
5063
- const updatedFormData = { name : 'updated' } ;
5064
-
5065
- const { rerender } = createFormComponent ( {
5066
- schema,
5067
- formData : initialFormData ,
5068
- experimental_componentUpdateStrategy : 'customDeep' ,
5069
- fields : { StringField : TestField } ,
5070
- } ) ;
5071
-
5072
- const initialRenderCount = renderCount ;
5073
-
5074
- // Re-render with different data - should cause field re-render even with customDeep
5075
- rerender ( {
5076
- schema,
5077
- formData : updatedFormData ,
5078
- experimental_componentUpdateStrategy : 'customDeep' ,
5079
- fields : { StringField : TestField } ,
5080
- } ) ;
5081
-
5082
- // With customDeep strategy and changed data, render count should increase
5083
- expect ( renderCount ) . to . be . greaterThan ( initialRenderCount ) ;
5084
- } ) ;
5085
-
5086
- it ( 'should handle nested object changes with customDeep strategy' , ( ) => {
5087
- const schema = {
5088
- type : 'object' ,
5089
- properties : {
5090
- user : {
5091
- type : 'object' ,
5092
- properties : {
5093
- name : { type : 'string' } ,
5094
- age : { type : 'number' } ,
5095
- } ,
5096
- } ,
5097
- } ,
5098
- } ;
5099
-
5100
- const initialFormData = { user : { name : 'John' , age : 25 } } ;
5101
-
5102
- const { rerender } = createFormComponent ( {
5103
- schema,
5104
- formData : initialFormData ,
5105
- experimental_componentUpdateStrategy : 'customDeep' ,
5106
- fields : { ObjectField : TestField } ,
5107
- } ) ;
5108
-
5109
- const initialRenderCount = renderCount ;
5110
-
5111
- // Re-render with same nested data - should not cause re-render
5112
- rerender ( {
5113
- schema,
5114
- formData : { user : { name : 'John' , age : 25 } } , // Same values, different object reference
5115
- experimental_componentUpdateStrategy : 'customDeep' ,
5116
- fields : { ObjectField : TestField } ,
5117
- } ) ;
5118
-
5119
- // With customDeep strategy, should not re-render for deep-equal data
5120
- expect ( renderCount ) . to . equal ( initialRenderCount ) ;
5121
-
5122
- // Now change nested data
5123
- rerender ( {
5124
- schema,
5125
- formData : { user : { name : 'John' , age : 26 } } , // Changed age
5126
- experimental_componentUpdateStrategy : 'customDeep' ,
5127
- fields : { ObjectField : TestField } ,
5128
- } ) ;
5129
-
5130
- // Should re-render when nested data actually changes
5131
- expect ( renderCount ) . to . be . greaterThan ( initialRenderCount ) ;
5132
- } ) ;
5133
-
5134
- it ( 'should handle array changes with customDeep strategy' , ( ) => {
5135
- const schema = {
5136
- type : 'object' ,
5137
- properties : {
5138
- items : {
5139
- type : 'array' ,
5140
- items : { type : 'string' } ,
5141
- } ,
5142
- } ,
5143
- } ;
5144
-
5145
- const initialFormData = { items : [ 'a' , 'b' , 'c' ] } ;
5146
-
5147
- const { rerender } = createFormComponent ( {
5148
- schema,
5149
- formData : initialFormData ,
5150
- experimental_componentUpdateStrategy : 'customDeep' ,
5151
- fields : { ArrayField : TestField } ,
5152
- } ) ;
5153
-
5154
- const initialRenderCount = renderCount ;
5155
-
5156
- // Re-render with same array data - should not cause re-render
5157
- rerender ( {
5158
- schema,
5159
- formData : { items : [ 'a' , 'b' , 'c' ] } , // Same values, different array reference
5160
- experimental_componentUpdateStrategy : 'customDeep' ,
5161
- fields : { ArrayField : TestField } ,
5162
- } ) ;
5163
-
5164
- // With customDeep strategy, should not re-render for deep-equal arrays
5165
- expect ( renderCount ) . to . equal ( initialRenderCount ) ;
5166
-
5167
- // Now change array data
5168
- rerender ( {
5169
- schema,
5170
- formData : { items : [ 'a' , 'b' , 'c' , 'd' ] } , // Added item
5171
- experimental_componentUpdateStrategy : 'customDeep' ,
5172
- fields : { ArrayField : TestField } ,
5173
- } ) ;
5174
-
5175
- // Should re-render when array data actually changes
5176
- expect ( renderCount ) . to . be . greaterThan ( initialRenderCount ) ;
5177
- } ) ;
5178
- } ) ;
5179
4975
} ) ;
0 commit comments