Currently I import Icons like this
//index.ts file for svgs
import BackArrow from './back-arrow.svg'
export {
BackArrow,
...
}
In a component i can now import and use it easily
import { BackArrow } from '../../assets/images'
....
return <BackArrow />
Now I tried to make a (child) component which should display two buttons and a text, which are passed by the parent component.
Parent uses the child like this:
<Button
label='hi'
iconLeft={BackIcon}
buttonTheme={BUTTONS_THEME.dark}
/>
Child looks like:
//Styled components (ThemedButton, Icon, Label)
const Button = ({ label, iconLeft, iconRight, theme}) => {
<ThemedButton>
{iconLeft && <Icon theme={theme} xml={iconLeft} />}
<Label theme={theme}>{label}</Label>
{iconRight && <Icon theme={theme} xml={iconRight} />}
</ThemedButton>
and this all works fine, if in the parent component I import the svg like this:
import BackArrow from '../../assets/images/back-arrow.svg'
but i want to use the "normal" way to import it as I do everywhere else in the App, like this: import { BackArrow } from '../../assets/images'
Anyone any idea how to solve this? I tried to pass the Icons like this <Button leftIcon={<BackArrow />}... />, but I can't get this working, as I don't know how I can use and style the icon in the child.