Created
September 24, 2019 14:20
-
-
Save ralfting/157d6401951a8c843fa9c6fac368c7f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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