dillon1000/react

Commit

Stop Mutating Merged Lifecycle Results

Summary:
Currently, `ReactClass` mutates values returned by `getDefaultProps`, `getInitialState`, and `getChildContext`. This is bad because the objects may, for example, be cached and re-used across instances of a React component.

This changes `ReactClass` to instead create a new object. In return for allocating a new object, I've replaced `mapObject` with a `for ... in` so that we are no longer allocating an unused object.

Fair trade, IMO.

Test Plan:
Ran unit tests successfully:

```
npm run jest
```

Conflicts:
	src/core/ReactCompositeComponent.js

Conflicts:
	src/class/ReactClass.js
Browse files
Changed paths2 files
First-parent comparison
M src/class/ReactClass.js ModifiedM src/core/__tests__/ReactCompositeComponent-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…