Skip to content

Instantly share code, notes, and snippets.

@ralfting
Created September 24, 2019 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfting/157d6401951a8c843fa9c6fac368c7f4 to your computer and use it in GitHub Desktop.
Save ralfting/157d6401951a8c843fa9c6fac368c7f4 to your computer and use it in GitHub Desktop.
setValues = (v: string): void => {
const lastChar = v.slice(-1);
const isComma = lastChar === ',';
const isSpace = lastChar === ' ';
if (isComma || isSpace) {
const delimiter = /,| /;
const notEmptyText = text => text.length > 0;
const emails = v
.slice(0, -1)
.split(delimiter)
.filter(notEmptyText);
const list = [...this.state.emailList, ...emails];
this.setState({ emailList: list });
this.inputRef.value = '';
this.dispatchAction(list);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment