Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mihansweatpants/0d78f30dc9823fb00908752f6fa2e670 to your computer and use it in GitHub Desktop.

Select an option

Save mihansweatpants/0d78f30dc9823fb00908752f6fa2e670 to your computer and use it in GitHub Desktop.

Destructuring let assignment

// Saw this inside reacts render method but mb this can be used somewhere else
render() {
  const { somethingAsync: { result } } = this.props;
  let total: null | number = null;

  // Grab something from result when it is available
  if (result != null) {
    ({ total }) = result;
  }
  
  return (/* stuff */)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment