How can I use the built-in Object.assign object in a reaction?

React is used to use merging, which is now deprecated and replaced with https://github.com/facebook/react/blob/dca7ffbe21d2b27d0c7ff898bbaa27dab84e4043/src/stubs/Object.assign.js

Just wondering if this destination version can be used in my code? Can I turn it on somehow? If so, which way should I use?

thanks.

+7
reactjs
source share
2 answers

You can use the package object.assign . This is the ES6 Object.assign () "ponyfill".

package.json:

"dependencies": { "object-assign": "^1.0.0", "react": "^0.12.0", ... }, 

Then where you want to use it:

 var assign = require('object-assign'); var MessageStore = assign({}, EventEmitter.prototype, { emitChange: function() { ... 

Facebook Flux Chat uses it.

+10
source share

I am using Object.assign posted with answer 0.12 ( require('react/lib/Object.assign') )

WARNING : This is a private API that can change at any time, so you cannot rely on it.

+4
source share

All Articles