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.
Object.assign() The Object.assign() method copies all enumerable own properties from one or more source objects to a target object. It returns the modified target object.
If we want to access all the values of nested objects then we have to use recursion to access each and every level of that object. And it can get more complicated according to the nesting of the object. That why we have to use recursion to get all the values and access the whole nested object.
Use the target. dataset property to access data attributes from the event object in React. The dataset property provides read and write access to the custom data attributes of the element. The property returns a Map of strings which can be converted to an object.
assign() which is used to copy the values and properties from one or more source objects to a target object. It invokes getters and setters since it uses both [[Get]] on the source and [[Set]] on the target. It returns the target object which has properties and values copied from the target object.
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.
I'm using Object.assign
shipped with react 0.12 (require('react/lib/Object.assign')
)
WARNING: this is private API which could change anytime so you can't really rely on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With