Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-email-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-email-autocomplete

📭 React hook for email autocomplete inputs

  • 1.0.5
  • npm
  • Socket score

Version published
Weekly downloads
134
increased by235%
Maintainers
1
Weekly downloads
 
Created
Source

Email Autocomplete Hook

📬 A React hook for email autocomplete inputs

undefined Known Vulnerabilities Known Vulnerabilities

This should work with other libraries including material-ui. Play with it here!

Installation

yarn add use-email-autocomplete       OR     npm i use-email-autocomplete

Usage

import useEmailAutocomplete from 'use-email-autocomplete'

const App = () => {
  const { email, bind } = useEmailAutocomplete()
  
  const onSubmit = () => /* you an use `email` from above just like from `state` */
  
  return <input {...bind} />
}

Custom Autocomplete Input

export const EmailInput = ({ onChange, ...props }) => {
  const { email, onChange: handleEmailChange, bind } = useEmailAutocomplete()
  
  const handleChange = e => {
    handleEmailChange(e)
    onChange(email)
  }

  return <input {...bind} {...props} onChange={handleChange} value={email} />
}

Usage with Material UI

Requires @material-ui/core: 4.0.0 and above.

import { TextField } from '@material-ui/core'

export const EmailInput = ({ onChange, ...props }) => {
  const { email, onChange: handleEmailChange, bind } = useEmailAutocomplete()
  
  const handleChange = e => {
    handleEmailChange(e)
    onChange(email)
  }

  return <TextField {...bind} {...props} onChange={handleChange} value={email} />
}

Examples

Options

OptionDescription
validationIf you don't want to validate, set this to false. Default is true
domainsAll email domains you want to autocomplete for. Defaults to a predefined array of email domains.

Option Usage

const {
  email, // value with suggestion
  value, // same as email (used for binding to input)
  onChange,
  ref,
  onBlur,
  onFocus,
  isValid,
  bind, // spread this on an `input` or component and it will do the rest
} = useEmailAutocomplete({
  domains: [],
  validation: true,
})

Keywords

FAQs

Package last updated on 23 Nov 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc