Answers for "react get data attribute"

3

react data attributes event

const removeId = e.target.getAttribute("data-remove");
Posted by: Guest on August-31-2020
0

react get data attribute from element

<div data-id={someId} >Test</div>

const id = e.target.getAttribute("data-id");
//alternate to getAttribute
const id = e.target.attributes.getNamedItem("data-id").value;
Posted by: Guest on February-03-2021

Browse Popular Code Answers by Language