The following is my piece of code where the inside component i.e. MultiSelectAssetDropdown does not get rendered. The console.log('comes here') doesn't come up, which clearly means that the loop isn't executing. However the prior console.log prints fine.. so I know this component is rendered. Also the component render after the loop executes perfectly fine.
<ul className="collapsible multiDropdownTag">
{ console.log('field',this.state.configDefaultVal)}
{ configDefaultVal.map(function (field) {
console.log('comes here');
return (
<MultiSelectAssetDropdown placeholder="" icon=""
label={field.defaultValues.DisplayName}
value={field.selectedValues}
disabled={this.state.disabledVal}
selectedValues={field.selectedValues}
className="multiselect"
defaultValues={field.defaultValues.values}
fieldValue="field1" id="field1"/>
)}, this)
}
<MultiSelectAssetDropdown placeholder="" icon=""
label="Sites"
value={abc}
siteId={this.state.details.siteId}
disabled={this.state.disabledVal}
selectedValues={abc}
defaultValues={abc}
fieldValue="sites" id="sites"/>
</ul>
Can somebody please point me in the right direction here?
The array looks like : [field1: Array(0), field0: Array(0)]
However when i do .length it gives 0
const finalFieldsArray = [];
_.forEach(configVal,function(selField,key){
_.forEach(configDefaultVal,function(defField,keys){
if(key == keys){
finalFieldsArray[keys]=[];
finalFieldsArray[keys]['selectedValues'] = selField;
finalFieldsArray[keys]['defaultValues'] = defField;
}
})
})
This finalFieldsArray is later set in state as configDefaultVal.