V
V
Vann Damm2021-02-10 12:31:02
typescript
Vann Damm, 2021-02-10 12:31:02

How to type inline svg?

There is a webpack loader @svgr/webpack for svg.
Declaration like this:

declare module "*.svg" {
  const content: any;
  export default content;
}

In the button component, I pass svg as children. And he can't pull up the type. I put Element - swears all the same. What type should he specify? Or maybe in the declaration some kind of return type can be delivered to it?
6023a78c74a05655657169.png
Tried it like this too):
children: Element |  (Element & ReactNodeArray & React.ReactPortal) | (Element & ReactNodeArray & React.ReactPortal & string) | (Element & number) | (Element & false) | (Element  & true) | (Element  & React.ReactElement),

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2021-02-10
@tyllo

There is a good example here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question