Fragments supporting dangerouslySetInnerHTML
See original GitHub issueIs your feature request related to a problem?
Currently seems like this is not possible:
// const icon = '<svg ...>'
<Fragment dangerouslySetInnerHTML={icon}></Fragment>
Type '{ dangerouslySetInnerHTML: string; }' is not assignable to type 'IntrinsicAttributes & { children?: any; }'.
Property 'dangerouslySetInnerHTML' does not exist on type 'IntrinsicAttributes & { children?: any; }'.ts(2322)
Describe the solution you’d like
<Fragment>
should accept dangerouslySetInnerHTML like other elements
Describe alternatives you’ve considered
Using spans everywhere
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Have Fragments support dangerouslySetInnerHTML #12014
To me Fragment seems to be the ideal candidate to support dangerouslySetInnerHTML so that you may inject HTML without wrapping elements.
Read more >Using Fragment to insert HTML rendered on the back end via ...
In my case, dangerouslySetInnerHTML was utilized to render plain HTML for a user to download; it was not ideal to have additional wrapper ......
Read more >Dangerously Set innerHTML | React
Improper use of the innerHTML can open you up to a cross-site scripting (XSS) attack. Sanitizing user input for display is notoriously error-prone,...
Read more >DOM Elements - React
dangerouslySetInnerHTML is React's replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it's easy to ......
Read more >react-dom-fragment - npm
A React Fragment that supports dangerously setting innerHTML. Latest version: 1.0.0, last published: 3 years ago.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will keep an eye open, but this is specially tricky in qwik because of the serialization requirements, and update after ssr. Thanks for the issue, but i will close since we will not implement this anytime soon
@manucorporat since you mentioned you wouldn’t be implementing this soon, what is our alternative?
We are considering migrating to Qwik + Qwik City from React + Next for our entire company and all projects.
We’re testing one project for migration and now we’re stuck at this.
In Next, we get data from a headless CMS. Inside this data, there is SVG tags. So SVG tags are not available at build time. We receive them from API.
In React, we could use:
This way, we could print the SVG using React and style it using Tailwind.
What should we do to migrate this code to Qwik + Qwik City?