Skip to content

Instantly share code, notes, and snippets.

@jh3y
Created November 5, 2020 12:58
Show Gist options
  • Save jh3y/55fb48f4dba81bc3c5e9097f3c3d0531 to your computer and use it in GitHub Desktop.
Save jh3y/55fb48f4dba81bc3c5e9097f3c3d0531 to your computer and use it in GitHub Desktop.
const myObject = {
a: 1,
b: 2,
...(false && { c: 3 }),
}
// myObject: { a: 1, b: 2 }
const myObject = {
a: 1,
b: 2,
...(true && { c: 3, d: 4 }),
}
// myObject: { a: 1, b: 2, c: 3, d: 4 }
const MyComponent = () => {
return <SomeOtherComponent {...(passOptionalProps && { cool: true, message: '👋' })} />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment