Skip to content

useInput

Nick Wylynko edited this page Nov 17, 2022 · 1 revision
import { useInput } from "react-raw-hooks/hooks/useInput"

Examples

Simple pass through to input

const App = () => {
  const input = useInput()

  const handleClick = () => {
    console.log(input.value)
  }

  return (
    <>
      <input {...input} />
      <button onClick={handleClick}>Continue</button>
    </>
  )
}

Multiple inputs

const App = () => {
  const name = useInput()
  const email = useInput()

  const handleClick = () => {
    console.log(name.value, email.value)
  }

  return (
    <>
      <input {...name} />
      <input {...email} />
      <button onClick={handleClick}>Continue</button>
    </>
  )
}
Clone this wiki locally