-
Notifications
You must be signed in to change notification settings - Fork 50.9k
Closed
Labels
Description
Do you want to request a feature or report a bug?
Hi, React Team. Thanks for your awesome work. I have a problem when using
dangerouslySetInnerHTML
What is the current behavior?
My example code like this:
//... the node.topic is a string
render() {
const { node, className, style } = this.props;
return (
<div
tabIndex={0}
contentEditable={true}
id="editor"
onKeyDown={this.handleKeyDown}
spellCheck={false}
onBlur={this.handleBlur}
onPaste={this.handlePaste}
ref={this.containerRef}
dangerouslySetInnerHTML={{ __html: node.topic }}
style={style}
/>
);
}
But I got unexpected html that looks like


What is the expected behavior?
It's hard for me to debug what's wrong with it. It's sometimes work, but sometimes will generate a <br/> tag.
Maybe the <br /> tag is generated by my browser ?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
react 16.7.0
react-dom 16.7.0
OS: macos 10.14.1 Beta (18B73a)
Chrome: 71.0.3578.98
Reactions are currently unavailable