I am developing a gallery site with Reactjs and want to pass multiple values in object format to a function as parameter when onclick.
But when I console the param in function, the value showing "[object object]".
Here is the code
<button onClick={handleToggleModal} data={{ id: value.tempid, demoUrl: value.demolink }}>More Info</button>
for the function
function handleToggleModal(e) {
let arr = {};
arr.push(e.currentTarget.getAttribute("data"));
console.log(e.currentTarget.getAttribute("data")); // Showing [object object] in console
}
Seem this is not working to use html attribute to pass object or array. Searched online but not able to find the question similar to this. Thanks for the help in advanced.