1

I have an svg image that I want to use as a background in a styled-component.

My code looks like this

import { ReactComponent as BackgroundImage } from './img/BackgroundImage.svg';

const StyledDiv = styled.div`
   background: url(${BackgroundImage});
`

This is giving an error, which is a typescript error.

Argument of type 'FunctionComponent>' is not assignable to parameter of type 'Interpolation & SVGProps & { children?: ReactNode; }, any>>'.

here is the code for the svg

<svg width="11px" height="12px" viewBox="0 0 11 12" xmlns="http://www.w3.org/2000/svg">
  <path d="M5.984 10.08l4.324-4.445.692.711L5.5 12 0 6.346l.692-.71 4.324 4.444V0h.968z" fill="currentColor" fill-rule="evenodd"/>
</svg>
Grant Humphries
  • 2,696
  • 2
  • 23
  • 24
peter flanagan
  • 9,195
  • 26
  • 73
  • 127

0 Answers0