Socket
Book a DemoInstallSign in
Socket

react-using-input

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-using-input

A custom hook for binding input value and validating.

1.0.42
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

React hook for binding input values and validating onchang.

Get Started by 3 steps

  • Attach Ref
  • const data = useInput(thatRef)
  • use it by data.get() data.set() data.onChange() data.validation()
import { useRef } from 'react'
import useInput from 'react-using-input'

const App = () => {
  const usernameRef = useRef()
  const username = useInput(usernameRef)
  /* 
    username.set(newvalue)
    username.onChange(value=>{
      if(value.length!=0) return ture
      return false
    })
    username.validation() will return 'true' or 'false' based on onChange event return value
  */


  const hobbyRef = useRef()
  const hobby = useInput(hobbyRef)

  return (
    <div>
      <form>
        username:
        <input type='text' name='firstname' ref={usernameRef} /> <br />
        hobby:
        <input type='text' name='hobby' ref={hobbyRef} /> <br />
        <button>submit</button>
      </form>
      <h5>{username.get()}</h5>
      <h5>{hobby.get()}</h5>
    </div>
  )
}
export default App

Keywords

react

FAQs

Package last updated on 15 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.