Skip to content

Is there any more efficent way other than using dangerouslySetInnerHTML to set svg string? #13493

@cooljacket

Description

@cooljacket

When I'm parsing markdown text, I will have a string whose content is a svg file, such as

<svg height="100" width="100">
<circle 
    cx="50" cy="50" r="40" 
    stroke="black" stroke-width="3" fill="red" />
</svg>

As far as now, it seems that the only way to render this svg string is to use dangerouslySetInnerHTML, I wanna to ask:

  1. Will this way inefficent?
  2. Is there any more efficent way in React?

Thanks for reading this issue.
Looking forward your awesome answers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions