Events in Next Js

  • When you use events in next js then always convert that component as client component through "use client". event like: onclick, onchange etc.
  • Example:


    "use client"
    import React from 'react'

    const Home = () => {
      return (
        <div>
          Home Page
          <button
            onClick={() => {
              alert("hello")
            }}
          >
            Click me
          </button>
        </div>
      )
    }

    export default Home




No comments:

Post a Comment

Debouncing and Throttling in JavaScript

Debouncing and Throttling - Made Simple! Think of these as traffic controllers for your functions: Debouncing = Wait until user stops, ...