Use Object.assign or Spread Operator in React/Redux? Which is a better practise

后端 未结 4 396
名媛妹妹
名媛妹妹 2020-11-30 04:32

I have some confusion about using Object.assign for React and Redux.

I read this article.

It says ES6 Does not supported by all browsers but I

4条回答
  •  失恋的感觉
    2020-11-30 04:59

    Ok may be I was not really right but this is from Dan Abramov (redux creator)

    Finally, you need to remember that Object.assign is a new method in ES6, so it is not natively available in all the browsers. You should use a polyfill, either the one that ships with Babel or a standalone Object.assign polyfill, to use it without risking crashing your website.

    Another option that doesn't require a polyfill is to use the new object spread operator, which is not part of ES6. However, it is proposed for ES7. It is fairly popular, and it is enabled in Babel if you use the stage two preset.

提交回复
热议问题