Skip to content

Commit 1f8adb9

Browse files
theKasheygregberge
authored andcommitted
fix: props merge order. #967 (#968)
1 parent b22f37e commit 1f8adb9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Diff for: src/reconciler/hotReplacementRender.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,20 @@ const hotReplacementRender = (instance, stack) => {
261261
const next = instance => {
262262
// copy over props as long new component may be hidden inside them
263263
// child does not have all props, as long some of them can be calculated on componentMount.
264+
const realProps = instance.props
264265
const nextProps = {
265-
...instance.props,
266+
...realProps,
266267
...(child.nextProps || {}),
267268
...(child.props || {}),
268269
}
269270

270271
if (isReactClass(instance) && instance.componentWillUpdate) {
271272
// Force-refresh component (bypass redux renderedComponent)
272-
instance.componentWillUpdate(nextProps, instance.state)
273+
instance.componentWillUpdate({ ...realProps }, instance.state)
273274
}
274275
instance.props = nextProps
275276
hotReplacementRender(instance, stackChild)
277+
instance.props = realProps
276278
}
277279

278280
// text node

Diff for: test/reconciler.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('reconciler', () => {
128128

129129
// what props should be used? Look like the new ones
130130
expect(second.willUpdate.mock.calls[0]).toEqual([
131-
{ children: '42', newProp: true, keyId: '2' },
131+
{ children: '42', keyId: '1' },
132132
null,
133133
{ children: '42', keyId: '1' },
134134
null,
@@ -137,7 +137,7 @@ describe('reconciler', () => {
137137
expect(second.willUpdate.mock.calls[1]).toEqual([
138138
{ children: '42', newProp: true, keyId: '2' },
139139
null,
140-
expect.any(Object), // Flake in React 15. Should be { children: '42', keyId: "1" },
140+
{ children: '42', keyId: '1' },
141141
null,
142142
])
143143

0 commit comments

Comments
 (0)