@samitouri / QOS-React-2 / commits / 97dac74c40

Use ReactInstanceMap

Move ReactInstanceMap to src/renderers/shared/shared to indicate that this logic is shared across implementations.

Andrew Clark committed Jul 26, 2016 at 13:23 UTC 97dac74c402e08f0edee7045e9d0406bdafcfc9c
2 files changed +3 -2
src/renderers/shared/fiber/ReactFiberBeginWork.js
+3 -2
@@ -46,6 +46,7 @@ var {
46 addToQueue,
47 mergeStateQueue,
48 } = require('ReactFiberStateQueue');
49 +var ReactInstanceMap = require('ReactInstanceMap');
50
51 module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getScheduler : () => Scheduler) {
52
@@ -149,7 +150,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
150 // Class component state updater
151 const updater = {
152 enqueueSetState(instance, partialState) {
152 - const fiber = instance._fiber;
153 + const fiber = ReactInstanceMap.get(instance);
154 const stateQueue = fiber.stateQueue ?
155 addToQueue(fiber.stateQueue, partialState) :
156 createStateQueue(partialState);
@@ -182,7 +183,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
183 workInProgress.stateQueue = createStateQueue(state);
184 }
185 // The instance needs access to the fiber so that it can schedule updates
185 - instance._fiber = workInProgress;
186 + ReactInstanceMap.set(instance, workInProgress);
187 instance.updater = updater;
188 } else if (typeof instance.shouldComponentUpdate === 'function') {
189 if (workInProgress.memoizedProps !== null) {
src/renderers/shared/shared/ReactInstanceMap.js renamed