I have an object and I need to return each one to check for its mapping result. My problem with my code below is on this line
style: { ...map[settings] },
I need a way to go through each setting and pass it to map. Not sure how to go about that the most efficient way in es6 ?
This is the value of settings been passed into the PassThrough component
const settings = {
block_background: GradientGreen,
block_spacing: padding,
};
Here is my Component
const PassThrough = ({ children, settings }) => {
const map = {
GradientGreen: {
background: 'linear-gradient(-95deg, green, blue 100%)',
},
padding: '20px',
};
const cloneChild = () => {
return cloneElement(children, {
style: { ...map[settings] },
});
};
return (
<Fragment>
{cloneChild()}
<Fragment/>
);
};