简体   繁体   中英

Render dynamic HTML as a value attribute to TextArea field in React.js

I have a simple textarea tag.

<textarea value={this.state.currentValue} disabled={this.props.readOnly}/>

I am trying to use dangerouslySetInnerHTML but not sure how to set correctly inside value attribute of TextArea tag. I know and used dangerouslySetInnerHTML which works fine when used with div, body tags.

 renderHtml: function(){
        return (
            dangerouslySetInnerHTML={{__html : this.state.currentValue}} 
        );
    }
   <TextArea value={this.renderHtml()} disabled={this.props.readOnly}/>

Looks like for any HTML element, only Strings are allowed as value. Solution for this is to use rich text WYSIWYG editors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM