Check out example codes for "html data attribute". It will help you in understanding the concepts better.

Code Example 1

<!-- data-* attritubes can be used on any html element -->
<div data-my-custom-data="true"></div>

Code Example 2

const article = document.querySelector('#electric-cars');
 
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "cars"

Code Example 3

var element = document.querySelector('.element');
var dataAttribute = element.getAttribute('data-name');
// replace "data-name" with your data attribute name

console.log(dataAttribute);

Code Example 4

<article
  id="voitureelectrique"
  data-columns="3"
  data-index-number="12314"
  data-parent="voitures">
...
</article>
var article = document.getElementById('voitureelectrique');
 
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "voitures"

Code Example 5

var dataId = $(this).attr("data-id");

Code Example 6

<a data-color="blue">
  	This tag contains a user-defined color attribute
</a>

<div data-link="https://github.com/k-vernooy">
	This tag contains a data attribute with a link
</div>

Learn ReactJs, React Native from akashmittal.com