MCPcopy
hub / github.com/facebook/react / enqueueSetState

Function enqueueSetState

packages/react-reconciler/src/ReactFiberClassComponent.js:167–190  ·  view source on GitHub ↗
(inst: any, payload: any, callback)

Source from the content-addressed store, hash-verified

165const classComponentUpdater = {
166 // $FlowFixMe[missing-local-annot]
167 enqueueSetState(inst: any, payload: any, callback) {
168 const fiber = getInstance(inst);
169 const lane = requestUpdateLane(fiber);
170
171 const update = createUpdate(lane);
172 update.payload = payload;
173 if (callback !== undefined && callback !== null) {
174 if (__DEV__) {
175 warnOnInvalidCallback(callback);
176 }
177 update.callback = callback;
178 }
179
180 const root = enqueueUpdate(fiber, update, lane);
181 if (root !== null) {
182 startUpdateTimerByLane(lane, 'this.setState()', fiber);
183 scheduleUpdateOnFiber(root, fiber, lane);
184 entangleTransitions(root, fiber, lane);
185 }
186
187 if (enableSchedulingProfiler) {
188 markStateUpdateScheduled(fiber, lane);
189 }
190 },
191 enqueueReplaceState(inst: any, payload: any, callback: null) {
192 const fiber = getInstance(inst);
193 const lane = requestUpdateLane(fiber);

Callers

nothing calls this directly

Calls 9

requestUpdateLaneFunction · 0.90
createUpdateFunction · 0.90
enqueueUpdateFunction · 0.90
startUpdateTimerByLaneFunction · 0.90
scheduleUpdateOnFiberFunction · 0.90
entangleTransitionsFunction · 0.90
markStateUpdateScheduledFunction · 0.90
getInstanceFunction · 0.85
warnOnInvalidCallbackFunction · 0.70

Tested by

no test coverage detected