react spread props code example

Example 1: spread operator react

{...this.state} spreads out the "own" enumerable properties in 
props as discrete properties on the Modal element you're creating. 
For instance, if this.props contained a: 1 and b: 2, then

<Modal {...this.state} title='Modal heading'>

would be the same as

<Modal a={this.state.a} b={this.state.b} title='Modal heading'>

Example 2: spreading object as props

// These two are equivalentfunction App1() {  return <Greeting firstName="Ben" lastName="Hector" />;}function App2() {  const props = {firstName: 'Ben', lastName: 'Hector'};  return <Greeting {...props} />;}