I have the following nested Array:
var productionSteps = [
0: {
displayName: "..."
final: ...
generateQRCode: ...
inputs: [
0: {
"assetGroup":"ValueAsset", "amount":1000
},
1: {...},
2: {...},
3: {...},
]
},
1: {...},
2: {...},
3: {...}
]
I want to access all of the assets of all of the production steps. But I want to save the right input assets to the according production step inside of a component.
I am using 'react-organizational-chart' to visualize this Data.
I have a productionNode component that is supposed to visualize one production step. This Node has an according asset component with the fitting assets to the production step.
My productionNode looks like this:
var input = props.asset
return (
<>
<Tree
lineWidth={'2px'}
lineColor={'green'}
lineBorderRadius={'10px'}
label={<div className='asset-container'>
<div className='top-divider'>
<p className='asset-name'>{props.nodeName}</p>
</div>
</div>}>
<TreeNode label={<Asset assetName={input}></Asset>}></TreeNode>
</Tree>
</>
);
The Asset Node looks like this:
return (
<>
<div className='asset-container'>
<div className='top-divider'>
<p className='asset-name'>{props.assetName}</p>
</div>
</div>
</>
);
I tried of doing it the following way:
<Tree
lineWidth={'2px'}
lineColor={'green'}
lineBorderRadius={'10px'}
label={<Asset assetName="Output Asset"></Asset>}
>
{Object.values(productionSteps).map((step: any, index) => {
step.inputs.map((material: any) => {
console.log(JSON.stringify(material.assetGroup))
return (
<TreeNode key={index} label={<ProductionNode asset={JSON.stringify(material.assetGroup)} nodeName={JSON.stringify(step.displayName)}></ProductionNode>}>
</TreeNode>
);
})
})}
</Tree>
This does not work. Also, I get an error in my Text Editor for the last Code Snippet:
"Type 'void[]' is not assignable to type 'ReactNode'.
Type 'void[]' is not assignable to type 'ReactFragment'.
The types returned by 'Symbol.iterator.next(...)' are incompatible between these types.
Type 'IteratorResult<void, any>' is not assignable to type 'IteratorResult<ReactNode, any>'.
Type 'IteratorYieldResult' is not assignable to type 'IteratorResult<ReactNode, any>'.
Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'.
Type 'void' is not assignable to type 'ReactNode'."