I'm working on a small project and I need to remove a specific component from a tree without removing its children.
Let's imagine the following code:
export const Component = () => {
return (
<>
<Background color="red">
<div>Red background</div>
</Background>
<Background color="blue">
<div>Blue backgound</div>
</Background>
</>
);
};
Using jscodesift, I would like to remove the <Background color="XXX"> opening and closing elements so that the output will be:
export const Component = () => {
return (
<>
<div>Red background</div>
<div>Blue backgound</div>
</>
);
};
For now, I'm stuck trying to find a way to remove the nodePath.node.openingElement and nodePath.node.closingElement without removing their children.
Does anybody know if what I'm trying to do is possible? What could help me solve this problem?