Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enable flag #60

Merged
merged 2 commits into from
Nov 23, 2022
Merged

Conversation

jopemachine
Copy link
Contributor

Changes

  • Support enable flag

Notes

I tested this after removing node-sass due to node-sass issue.

Please let me know if node-sass should be removed from dev-dependency.

Manual Test

Test code

  enableToCreateEmail({ emailCnt }: { emailCnt: number }) {
    if (emailCnt < 2) {
      return true;
    }
    return false;
  };

  onRejectHandler() {
    alert("Reached max email count");
  }

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

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

Result

Sep-17-2020 17-12-51

When I tried to add more than two emails, the callback function I specified was executed.

@rishav394
Copy link

Merge!!!

This was referenced Feb 12, 2021
@thomasJang thomasJang merged commit 92390b8 into axisj:master Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants