You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In let params all parameters for fetching data will merge recursively using lodash merge. The issue is when you have an object that has a key with a value of undefined, that undefined will not merge.
When dynamically overriding the searchInfo with opt?.searchInfo, the searchInfo object's key with a defined value and opt?.searchInfo with a key value is undefined, resulting in unexpected behavior. This scenario is utilized in business logic where occasionally setting the searchInfo key to undefined is necessary to meet requirements.
constcustomizer=(objValue: any,srcValue: any,key: any,obj: any): void=>{// Check if the values are different and if the source value is undefinedif(objValue!==srcValue&&(typeofsrcValue==='undefined'||srcValue===undefined)){// Set the object's key to the source valueobj[key]=srcValue;}};// Original object with searchInfoletobj1={level1: {level2: {value1: 1,value2: 'hello',value3: {test1: 'hello world',test2: 'hello world test2 obj1',},},},anotherKey: 'value',};// Object with opt?.searchInfoletobj2={level1: {level2: {value1: undefined,value2: 'world',value3: {test1: 'hello world obj2',test2: undefined,},},},anotherKey: undefined,};console.log('params test',mergeWith({},obj1,obj2,customizer));
Describe the bug
In
let params
all parameters for fetching data will merge recursively using lodash merge. The issue is when you have an object that has a key with a value of undefined, that undefined will not merge.When dynamically overriding the
searchInfo
withopt?.searchInfo
, thesearchInfo
object's key with a defined value andopt?.searchInfo
with a key value is undefined, resulting in unexpected behavior. This scenario is utilized in business logic where occasionally setting thesearchInfo
key to undefined is necessary to meet requirements.Reference
59b309a
Reproduction and Expected Output
System Info
The text was updated successfully, but these errors were encountered: