Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
use-email-autocomplete
Advanced tools
📬 A React hook for email autocomplete inputs
npm i use-email-autocomplete
This should work with other libraries including material-ui
.
Play with it here!
⚠️ email
cannot be destructured. It must be used like email.address
and email.isValid
⚠️
import useEmailAutocomplete from 'use-email-autocomplete'
const App = () => {
const { email, bind } = useEmailAutocomplete()
const onSubmit = () => /* you an use `email.address` from above just like from `state` */
return <input {...bind} />
}
⚠️ email
cannot be destructured. It must be used like email.address
and email.isValid
⚠️
export const EmailInput = ({ onChange, ...props }) => {
const { email, onChange: handleEmailChange, bind } = useEmailAutocomplete()
const { address, isValid } = email // WRONG, DO NOT DO THIS
const handleChange = e => {
handleEmailChange(e)
if (!email.isValid) conosle.log('Email is not valid') // RIGHT
onChange(email.address) // RIGHT
}
return <input {...bind} {...props} onChange={handleChange} />
}
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.address)
}
return <TextField {...bind} {...props} onChange={handleChange} />
}
Option | Description |
---|---|
validation | If you don't want to validate, set this to false. Default is true |
domains | All email domains you want to autocomplete for. Defaults to a predefined array of email domains. |
const {
// `email` is the `value` + `auto suggestion`
email: { address, isValid },
// spread `bind` on an `input` or component and it will
// apply all html valid attributes
bind,
// everything within `bind` is below. `bind.value` through `bind.onFocus`
value,
onChange,
ref,
onBlur,
onFocus,
} = useEmailAutocomplete({
domains: [],
validation: true,
})
FAQs
📭 React hook for email autocomplete inputs
The npm package use-email-autocomplete receives a total of 97 weekly downloads. As such, use-email-autocomplete popularity was classified as not popular.
We found that use-email-autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.