DEV Community

Manoj Manoharan
Manoj Manoharan

Posted on

1

Use push method without push ! in react

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;

Enter fullscreen mode Exit fullscreen mode

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay