You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* React calls this method so that you can compare the previous and the next props, and decide whether you need to update the underlying instance or not. If you don't need to update it, return `null`. If you need to update it, you can return an arbitrary object representing the changes that need to happen. Then in `commitUpdate` you would need to apply those changes to the instance.
153
-
*
154
-
* This method happens **in the render phase**. It should only *calculate* the update — but not apply it! For example, the DOM renderer returns an array that looks like `[prop1, value1, prop2, value2, ...]` for all props that have actually changed. And only in `commitUpdate` it applies those changes. You should calculate as much as you can in `prepareUpdate` so that `commitUpdate` can be very fast and straightforward.
155
-
*
156
-
* See the meaning of `rootContainer` and `hostContext` in the `createInstance` documentation.
157
-
*/
158
-
prepareUpdate(
159
-
instance: Instance,
160
-
type: Type,
161
-
oldProps: Props,
162
-
newProps: Props,
163
-
rootContainer: Container,
164
-
hostContext: HostContext,
165
-
): UpdatePayload|null;
166
-
167
154
/**
168
155
* Some target platforms support setting an instance's text content without manually creating a text node. For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.
* Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism.
227
+
* Set this to true to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism.
* To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:
261
-
*
262
-
* ```
263
-
* import {
264
-
* DiscreteEventPriority,
265
-
* ContinuousEventPriority,
266
-
* DefaultEventPriority,
267
-
* } from 'react-reconciler/constants';
268
-
*
269
-
* const HostConfig = {
270
-
* // ...
271
-
* getCurrentEventPriority() {
272
-
* return DefaultEventPriority;
273
-
* },
274
-
* // ...
275
-
* }
276
-
*
277
-
* const MyRenderer = Reconciler(HostConfig);
278
-
* ```
279
-
*
280
-
* The constant you return depends on which event, if any, is being handled right now. (In the browser, you can check this using `window.event && window.event.type`).
281
-
*
282
-
* - **Discrete events**: If the active event is directly caused by the user (such as mouse and keyboard events) and each event in a sequence is intentional (e.g. click), return DiscreteEventPriority. This tells React that they should interrupt any background work and cannot be batched across time.
283
-
*
284
-
* - **Continuous events**: If the active event is directly caused by the user but the user can't distinguish between individual events in a sequence (e.g. mouseover), return ContinuousEventPriority. This tells React they should interrupt any background work but can be batched across time.
285
-
*
286
-
* - **Other events / No active event**: In all other cases, return DefaultEventPriority. This tells React that this event is considered background work, and interactive events will be prioritized over it.
287
-
*
288
-
* You can consult the `getCurrentEventPriority()` implementation in `ReactDOMHostConfig.js` for a reference implementation.
* This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload` is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward.
336
+
* This method should mutate the instanceto match nextProps.
383
337
*
384
-
* The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
338
+
* The internalHandle data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
* This method is called during render to determine if the Host Component type and props require some kind of loading process to complete before committing an update.
* This method may be called during render if the Host Component type and props might suspend a commit. It can be used to initiate any work that might shorten the duration of a suspended commit.
* This method is called just before the commit phase. Use it to set up any necessary state while any Host Components that might suspend this commit are evaluated to determine if the commit must be suspended.
534
+
*/
535
+
startSuspendingCommit(): void;
536
+
537
+
/**
538
+
* This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
539
+
*/
540
+
suspendInstance(type: Type,props: Props): void;
541
+
542
+
/**
543
+
* This method is called after all `suspendInstance` calls are complete.
544
+
*
545
+
* Return `null` if the commit can happen immediately.
546
+
*
547
+
* Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this callback will initiate the commit when called. The return value is a cancellation function that the Reconciler can use to abort the commit.
0 commit comments