Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

76
Views
What is the equal code for OnChange on React Class Component , on React Function Component

what is the equal code for this on React Function Component without using defaultValue?

<input onChange((e)=>{this.setState({title : this.target.value})}) value={value} />
7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

I think this is what your asking:

import { useState } from "react";

function MyComponent({defaultValue}) {
  const [inputValue, setInputValue] = useState(defaultValue);
  return (
    <form>
      <input
        type="text"
        onChange={(e) => setInputValue(e.target.value)}
        value={inputValue}
      />
    </form>
  );
}
7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.