Streaming on Twitch twice a week

Flat arrays to object arrays


If an array contains flat values, we can quickly turn those into objects by mapping over them. The name we give them in the call to becomes the name of the objects’ property when we do it like this.

// turn these strings into objects, where they become `name`-properties
['John', 'Paul', 'George', 'Ringo'].map(name => ({ name }))
// ⇒ [
//     { name: 'John'   },
//     { name: 'Paul'   },
//     { name: 'George' },
//     { name: 'Ringo'  }
//   ]

More fire tips

Namespacing styled-components

To improve the readability of React components, we can import the styled-components they use from another file under a ui-namespace.

Read fire tip

Read all fire tips →