I have the following component:
import React, { ReactElement } from 'react'
interface Props {
icon: JSX.Element; // should accept only svg
fill?: string;
stroke?: string;
}
export default function AppIcon(props: Props): ReactElement {
// TODO:
// Replace: svg *[fill] = props.fill
// Replace: svg *[stroke] = props.stroke
}
As you can see, the component accepts an icon of JSX.Element (not sure how can I strict it to SVG only).
After that, it should look in the icon
tree for children who has fill
and stroke
attribute and replace accordingly. Meaning, if there's a path with fill
, it will replace it with the given fill. If a path doesn't have a fill
, then it won't be added.
How can I achieve this behavior?