I have custom component in which i map attributes. In this component I have label which have css class assigned. But i also want optional inline style for this label. The problem is that in react I need to surround inline style with curly braces and i can't escape them or set them correctly in component. How to resolve this?
Code from component:
const CustomComponent = ({items, name}) => (
<fieldset>
{items
.map((item, index) => ({item, id: `${name || 'dod'}-${item.value || index}`}))
.map(({item, id}) =>
<div key={id}
className="className1">
<input
id={id}
name={name}
type="text"
/>
<label htmlFor={id} className="className" style={item.style}>
{item.label}
</label>
</div>
)}
</fieldset>
);
Code from rendered .jsx
<CustomComponent
name="name"
items={[{
value: 'value',
label: 'label',
style: {{display: 'inline'}} -> not working
}]}
/>
item.style? It must be an object literal ? if you are mapping, usekey.