In React, what do the three points ... do?

Updated: Nov 1, 2019






As you are conscious, The Spread attributes (...) that the name indicates allow expansion of a word.


Example:


Let's have a real example:

Suppose we have object like below:

var student= {
    name: 'Honey',
    age: 35 
}

By using The spread attribute (...) we can use this object as below:

<Modal {...student} title='Modal heading' animation={false} />

which is equivalent to :

<Modal name={student.name} age={student.age} title='Modal heading' animation={false} />

Conclusion:

So in short, it's a neat short-cut, that's all !!

0 views
Never Miss a Post. Subscribe Now!

Contact Us: nawabblog@gmail.com

Location : Bangalore India.

© 2019 proudly created  by Nawab Ahmad. 

  • Nawab Ahmad
  • Grey Twitter Icon
  • Nawab Ahmad