How to destructure object and ignore one of the results with React?

To destructure object and ignore one of the results with React, we can use the rest operator.

For instance, we write

const { styles, ...otherProps } = this.props;
const section = cloneElement(this.props.children, {
  className: styles.section,
  ...otherProps,
});

to get the otherProps object by destructuring.

otherProps has all the properties of this.props except styles.

Then we can use otherProps by spreading it in the object we call cloneElement with.