Skip to content
Related Articles
Open in App
Not now

Related Articles

What is the use of data-reactid attribute in HTML ?

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 29 Jun, 2020
Improve Article
Save Article

The data-reactid attribute is a custom attribute that react can easily identify its components within the DOM. Just like the HTML “classes” and “id” attributes, “data-reactid” helps in uniquely identifying the element .

Since sharing the entire object references in a serialized order between the server and the client is potentially expensive. Hence, using these id’s react internally builds a representation of references of the nodes (used to build up your application) present in the DOM. When the app is rendered and the react is loaded at the client the only data it shares to the server is the “data-reactid” attributes.

Then the “data-reactid” attributes convert back into the data structure provided and displays the data without actually rendering the entire data structure at the client.

Example: Importing the data from the file Data.js using “react-id” attribute in the app.js).


export const Data=[
 id: '.1',
 node: Div,
 children: [
     id: '.2',
     node: Span,
     children: [
         id: '.2’,
         node: Input,
         children: []


import React, { Component } from 'react';
import {Data} from './src/data';
class App extends Component{
            <div data-reactid='.1'>
                <span data-reactid='.2'>
                  <input data-reactid='.3' />
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!