Hacker News new | ask | show | jobs
by djklanac 2722 days ago
One of my favorites:

spread operator shorthand for passing component props.

Suppose: const now = moment()

Then, you can pass it down to a component like this:

<TimeInput {...{now}} />

Which is equivalent to

<TimeInput now={now} />

With many props, it becomes easier on the eyes and differentiates from passing event handlers e.g. <TimeInput {...{now}} myHandler={this.handleKeyPress} />