55
export type Instance = {
56
// Reference to the shadow node.
57
node: Node,
58
- nativeTag: number,
59
- viewConfig: ViewConfig,
60
- currentProps: Props,
61
- // Reference to the React handle (the fiber)
62
- internalInstanceHandle: Object,
63
- // Exposed through refs.
64
- publicInstance: ReactFabricHostComponent,
58
+ canonical: {
59
+ nativeTag: number,
60
+ viewConfig: ViewConfig,
61
+ currentProps: Props,
62
+ // Reference to the React handle (the fiber)
63
+ internalInstanceHandle: Object,
64
+ // Exposed through refs.
65
+ publicInstance: ReactFabricHostComponent,
66
+ },
67
};
68
export type TextInstance = {node: Node, ...};
69
export type HydratableInstance = Instance | TextInstance;
150
151
return {
152
node: node,
151
- nativeTag: tag,
152
- viewConfig,
153
- currentProps: props,
154
- internalInstanceHandle,
155
- publicInstance: component,
153
+ canonical: {
154
+ nativeTag: tag,
155
+ viewConfig,
156
+ currentProps: props,
157
+ internalInstanceHandle,
158
+ publicInstance: component,
159
+ },
160
};
161
}
162
226
}
227
228
export function getPublicInstance(instance: Instance): null | PublicInstance {
225
- if (instance.publicInstance != null) {
226
- return instance.publicInstance;
229
+ if (instance.canonical != null && instance.canonical.publicInstance != null) {
230
+ return instance.canonical.publicInstance;
231
}
232
233
// For compatibility with the legacy renderer, in case it's used with Fabric
253
newProps: Props,
254
hostContext: HostContext,
255
): null | Object {
252
- const viewConfig = instance.viewConfig;
256
+ const viewConfig = instance.canonical.viewConfig;
257
const updatePayload = diff(oldProps, newProps, viewConfig.validAttributes);
258
// TODO: If the event handlers have changed, we need to update the current props
259
// in the commit phase but there is no host config hook to do it yet.
260
// So instead we hack it by updating it in the render phase.
257
- instance.currentProps = newProps;
261
+ instance.canonical.currentProps = newProps;
262
return updatePayload;
263
}
264
337
}
338
return {
339
node: clone,
336
- nativeTag: instance.nativeTag,
337
- viewConfig: instance.viewConfig,
338
- currentProps: instance.currentProps,
339
- internalInstanceHandle: instance.internalInstanceHandle,
340
- publicInstance: instance.publicInstance,
340
+ canonical: instance.canonical,
341
};
342
}
343
347
props: Props,
348
internalInstanceHandle: Object,
349
): Instance {
350
- const viewConfig = instance.viewConfig;
350
+ const viewConfig = instance.canonical.viewConfig;
351
const node = instance.node;
352
const updatePayload = create(
353
{style: {display: 'none'}},
355
);
356
return {
357
node: cloneNodeWithNewProps(node, updatePayload),
358
- nativeTag: instance.nativeTag,
359
- viewConfig: instance.viewConfig,
360
- currentProps: instance.currentProps,
361
- internalInstanceHandle: instance.internalInstanceHandle,
362
- publicInstance: instance.publicInstance,
358
+ canonical: instance.canonical,
359
};
360
}
361