How to change data-reactid
attributes to my custom attributes like data-hello="world"
in react?
<a data-reactid="......" ></a>
How to change data-reactid
attributes to my custom attributes like data-hello="world"
in react?
<a data-reactid="......" ></a>
Update: As of React 15, data-reactid has been removed and is never written to the DOM as an attribute
The short answer: Don't touch the data-reactid. Ever. It is a vital part of React, and basically used to perform the correct DOM manipulations when the virtual DOM tree is changed. Pretend it's not there.
However, you can add your own data- attributes in any way you wish:
render () {
return (
<h1 data-hello={this.props.hello}>{this.props.title}</h1>
);
}
Working example: https://jsfiddle.net/0or98zjx/
React creates the virtual DOM a, it measures the difference between the actual DOM and and virtual DOM if there is any change it will change the virtual DOM. So react.id will be a part of virtual DOM .