mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
[RT] Minor clean up (#11122)
* Rename rootNodeID -> tag * Process RT props before forwarding them along This is needed because the children prop can't be serialized. Also, some minor placeholder for events.
This commit is contained in:
committed by
GitHub
parent
44c32fc268
commit
7ec46e0fb0
@@ -21,14 +21,12 @@ var ReactNativeRTEventEmitter = {
|
||||
* @param {object} nativeEventParam Object passed from native.
|
||||
*/
|
||||
receiveEvent: function(
|
||||
rootNodeID: number,
|
||||
tag: number,
|
||||
topLevelType: string,
|
||||
nativeEventParam: Object,
|
||||
) {
|
||||
var nativeEvent = nativeEventParam;
|
||||
var props = ReactNativeRTComponentTree.getFiberCurrentPropsFromTag(
|
||||
rootNodeID,
|
||||
);
|
||||
var props = ReactNativeRTComponentTree.getFiberCurrentPropsFromTag(tag);
|
||||
if (props == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,26 @@ export type TextInstance = number;
|
||||
|
||||
const {precacheFiberNode, updateFiberProps} = ReactNativeRTComponentTree;
|
||||
|
||||
function processProps(instance: number, props: Props): Object {
|
||||
const propsPayload = {};
|
||||
for (var key in props) {
|
||||
if (key === 'children') {
|
||||
// Skip special case.
|
||||
continue;
|
||||
}
|
||||
var value = props[key];
|
||||
if (typeof value === 'function') {
|
||||
value = {
|
||||
style: 'rt-event',
|
||||
event: key,
|
||||
tag: instance,
|
||||
};
|
||||
}
|
||||
propsPayload[key] = value;
|
||||
}
|
||||
return propsPayload;
|
||||
}
|
||||
|
||||
const NativeRTRenderer = ReactFiberReconciler({
|
||||
appendChild(parentInstance: Instance, child: Instance | TextInstance): void {
|
||||
RTManager.appendChild(parentInstance, child);
|
||||
@@ -70,7 +90,7 @@ const NativeRTRenderer = ReactFiberReconciler({
|
||||
internalInstanceHandle: Object,
|
||||
): void {
|
||||
updateFiberProps(instance, newProps);
|
||||
RTManager.updateNode(instance, newProps);
|
||||
RTManager.updateNode(instance, processProps(instance, newProps));
|
||||
},
|
||||
|
||||
createInstance(
|
||||
@@ -81,9 +101,9 @@ const NativeRTRenderer = ReactFiberReconciler({
|
||||
internalInstanceHandle: Object,
|
||||
): Instance {
|
||||
const tag = ReactNativeRTTagHandles.allocateTag();
|
||||
RTManager.createNode(tag, type, props);
|
||||
precacheFiberNode(internalInstanceHandle, tag);
|
||||
updateFiberProps(tag, props);
|
||||
RTManager.createNode(tag, type, processProps(tag, props));
|
||||
return tag;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user