I want to reuse my component for multiple pages. so, I have to change img src in styled.img component as passing props.
is it possible to change image src on styled component ?
I applied my code like below. it's not working..
//logic
import Myimg from './img/icon_my';
const OngoingLists = ({ ...props }) => {
return (
<ListsOutWrap>
<ProgramListWrap {...props}>
<IconWrap {...props} >
<MyIcon {...props} />
</IconWrap>
</<ProgramListWrap>
</ListsOutWrap>
);
}
// styled component
const MyIcon = styled.img.attrs({
src: props => props.Img || { Myimg },
})`
width: 100%;
`;
I tried like above, any image doesn't show...even default img file doesn't show.. how can I change src file by using props ?? should I use background-image ?
thanks for ur help in advance ! :)