10 ms·
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
by djklanac 8y 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} />