jopemachine / react-multi-email

Forked from https://github.com/jsdevkr/react-multi-email

Home Page:http://react-multi-email.jsdev.kr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm version

react-multi-email (forked)

This version support below additional features

This version could be removed when the above PRs are merged or closed because of finding some fault.

See Demo

Installation

npm install @jopemachine/react-multi-email

Usage

import * as React from 'react';
import { ReactMultiEmail, isEmail } from 'react-multi-email';
import 'react-multi-email/style.css';

interface IProps {}
interface IState {
  emails: string[];
}
class Basic extends React.Component<IProps, IState> {
  state = {
    emails: [],
  };

  render() {
    const { emails } = this.state;

    return (
      <>
        <h3>Email</h3>
        <ReactMultiEmail
          placeholder="placeholder"
          emails={emails}
          onChange={(_emails: string[]) => {
            this.setState({ emails: _emails });
          }}
          validateEmail={email => {
            return isEmail(email); // return boolean
          }}
          getLabel={(
            email: string,
            index: number,
            removeEmail: (index: number) => void,
          ) => {
            return (
              <div data-tag key={index}>
                {email}
                <span data-tag-handle onClick={() => removeEmail(index)}>
                  ×
                </span>
              </div>
            );
          }}
        />
        <br />
        <h4>react-multi-email value</h4>
        <p>{emails.join(', ') || 'empty'}</p>
      </>
    );
  }
}

export default Basic;

License

MIT

If you don't mind, don't forget to press "star" before leaving.

About

Forked from https://github.com/jsdevkr/react-multi-email

http://react-multi-email.jsdev.kr

License:MIT License


Languages

Language:TypeScript 49.8%Language:Less 35.3%Language:CSS 5.9%Language:JavaScript 4.6%Language:HTML 4.5%