Skip to content

Commit ffeb409

Browse files
AndrewLeedhamodinhb
authored andcommitted
Add dangerouslySetInnerHTML documentation
developit#17 (comment)
1 parent 6eb142b commit ffeb409

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ The above outputs the following HTML:
118118
</div>
119119
```
120120

121+
### dangerouslySetInnerHTML
122+
As with React and Preact you can provide the prop `dangerouslySetInnerHTML` with an object containing `{__html: '<h1>HTML Content</h1>'}` to directly set the HTML content of an element. However, this is not advisable as it will ignore any children passed to it, and removes the benefits of JSX.
123+
124+
Here is an example:
125+
```js
126+
<div dangerouslySetInnerHTML={{__html: '<h1>HTML Content</h1>'}}>
127+
Overwritten content!
128+
</div>
129+
```
130+
131+
The above outputs the following HTML:
132+
```html
133+
<div>
134+
<h1>HTML Content</h1>
135+
</div>
136+
```
137+
121138
## Config
122139

123140
### Typescript

0 commit comments

Comments
 (0)