How can I use the built in Object.assign in react?

reactjs

Solution

You can use object.assign package. It is an 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() {
  ...

The Facebook Flux Chat example uses it.

Problem

React used to have a merge util, that is now deprecated and replaced with https://github.com/facebook/react/blob/dca7ffbe21d2b27d0c7ff898bbaa27dab84e4043/src/stubs/Object.assign.js Just wonder if it's possible to use this version of assign in my code? Is it somehow possible to include it? If so, what path should I use? thanks.

Original source