Skip to content

Add dangerouslySetInnerHTML documentation #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,20 @@ The above outputs the following HTML:
</ul>
</div>
```

### dangerouslySetInnerHTML
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.

Here is an example:
```js
<div dangerouslySetInnerHTML={{__html: '<h1>HTML Content</h1>'}}>
Overwritten content!
</div>
```

The above outputs the following HTML:
```html
<div>
<h1>HTML Content</h1>
</div>
```