Horje
react hook from Code Example
npm hook form
import React from 'react';import { useForm } from 'react-hook-form'; function App() {  const { register, handleSubmit, errors } = useForm(); // initialise the hook  const onSubmit = (data) => {    console.log(data);  };   return (    <form onSubmit={handleSubmit(onSubmit)}>      <input name="firstname" ref={register} /> {/* register an input */}            <input name="lastname" ref={register({ required: true })} />      {errors.lastname && 'Last name is required.'}            <input name="age" ref={register({ pattern: /\d+/ })} />      {errors.age && 'Please enter number for age.'}            <input type="submit" />    </form>  );}
components react to hooks
import React, { useState } from 'react';
function Example() {
  // Declare a new state variable, which we'll call "count"  const [count, setCount] = useState(0);
  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
Source: reactjs.org
react hook from
react hook from




Javascript

Related
error while updating linecap of a view polyline react-native-maps Code Example error while updating linecap of a view polyline react-native-maps Code Example
how to get data from jsonplaceholder Code Example how to get data from jsonplaceholder Code Example
How long does it take to learn to code Code Example How long does it take to learn to code Code Example
javascript auto detect if select input changed Code Example javascript auto detect if select input changed Code Example
javascript check if url returns 200 Code Example javascript check if url returns 200 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10