What does the three dots in react do?

    xiaoxiao2021-03-26  39

    http://stackoverflow.com/a/41640566/2177408

    As you know ... are called spread operator which the name represents it allows an expression to be expanded.

    var parts = ['two', 'three']; var numbers = ['one', ...parts, 'four', 'five']; // ["one", "two", "three", "four", "five"]

    And in this case(I'm gonna simplify it).

    //just assume we have an object like this: var person= { name: 'Alex', age: 35 }

    This:

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

    is equal to

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

    So in short, it's a neat short-cut, we can say.

    转载请注明原文地址: https://ju.6miu.com/read-650311.html

    最新回复(0)