Use ReactInstanceMap

Move ReactInstanceMap to src/renderers/shared/shared to indicate that
this logic is shared across implementations.
This commit is contained in:
Andrew Clark
2016-09-13 15:26:47 -07:00
committed by Sebastian Markbage
parent d218158d22
commit 97dac74c40
2 changed files with 3 additions and 2 deletions
@@ -46,6 +46,7 @@ var {
addToQueue,
mergeStateQueue,
} = require('ReactFiberStateQueue');
var ReactInstanceMap = require('ReactInstanceMap');
module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getScheduler : () => Scheduler) {
@@ -149,7 +150,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
// Class component state updater
const updater = {
enqueueSetState(instance, partialState) {
const fiber = instance._fiber;
const fiber = ReactInstanceMap.get(instance);
const stateQueue = fiber.stateQueue ?
addToQueue(fiber.stateQueue, partialState) :
createStateQueue(partialState);
@@ -182,7 +183,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
workInProgress.stateQueue = createStateQueue(state);
}
// The instance needs access to the fiber so that it can schedule updates
instance._fiber = workInProgress;
ReactInstanceMap.set(instance, workInProgress);
instance.updater = updater;
} else if (typeof instance.shouldComponentUpdate === 'function') {
if (workInProgress.memoizedProps !== null) {