Skip to content

Instantly share code, notes, and snippets.

@oliversisson
Created April 27, 2016 16:47
Show Gist options
  • Save oliversisson/d4a912eb12351f95bf1d7d4eefbe0639 to your computer and use it in GitHub Desktop.
Save oliversisson/d4a912eb12351f95bf1d7d4eefbe0639 to your computer and use it in GitHub Desktop.
Improvement to setMessageStatus. It is much more terse. It is more functional: using a map, rather than a for-loop
setMessageStatus(uniqueId, status) {
return this.state.messages.map(function(message) {
if (message.uniqueId !== uniqueId) {
return message;
}
return Object.assign({}, message, {status});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment