Skip to content

Instantly share code, notes, and snippets.

@Swizec
Created May 23, 2016 23:15
Show Gist options
  • Save Swizec/f53c15cf68166295f19bc7e70ed31db1 to your computer and use it in GitHub Desktop.
Save Swizec/f53c15cf68166295f19bc7e70ed31db1 to your computer and use it in GitHub Desktop.
// Contrived example of destructuring objects where local context has different name for keys
// Think of it as "When giving a value, the context has a different name for it than when getting the value"
// LabelX becomes just X when you're a label.
// There are many reasons why this isn't (and maybe shouldn't be) possible
let makeInput = ({x, value}) => (
<DoInputStuff />
)
let makeLabel = ({x, label}) => (
<DoLabelStuff />
)
// params = {labelX: 50, inputX: 500, value: .., label: ...}
let makeLabeledInput = (params) => (
makeLabel(params);
makeInput(params);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment