import { Fragment, useState } from "react";
const Login = () =>{
const [data,setData] = useState([]); // step 1 create useState
// An obj to push
const obj = {
name:"manojconcept",
age:"unlimited"
}
// Adding HandleClick function
const handClick = () =>{
setData([...data,obj]) // by using spread operator
}
return(
<>
<button onClick={handClick}>
click Me
</button>
{
data.map((ele,ind)=>{
return(
<Fragment key={ind}>
<p>
{ele.name}
</p>
<p>
{ele.age}
</p>
</Fragment>
)
})
}
</>
)
}
export default Login;
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)