how can i manage the component state in nextjs?

What you have defined here is a functional Component. Only class components can use this. So either you could change what you have to a class component or you can simply have state in a functional component using the useState hook like this:

import { useState } from 'react'; 

export default function TalentSearch() {
  const [value, setValue] = useState("value")

  return (
      <button onClick={clicked}>click me</button>
      <input type="text" name="search" />

Some notes

  • just call value anywhere within the component to get the current state and if you would like to change it use the set state function like this: setValue(new state)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top