react 15.0.0 → 15.0.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-with-addons.js +41 -8
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +41 -8
- package/dist/react.min.js +6 -6
- package/lib/DOMPropertyOperations.js +1 -2
- package/lib/EventPluginUtils.js +1 -1
- package/lib/IOSDefaultEventPluginOrder.js +16 -0
- package/lib/IOSNativeBridgeEventPlugin.js +57 -0
- package/lib/NativeMethodsMixin.js +165 -0
- package/lib/React.js +18 -1
- package/lib/ReactDOMComponent.js +7 -0
- package/lib/ReactDOMOption.js +10 -0
- package/lib/ReactNative.js +71 -0
- package/lib/ReactNativeAttributePayload.js +397 -0
- package/lib/ReactNativeBaseComponent.js +196 -0
- package/lib/ReactNativeComponentEnvironment.js +38 -0
- package/lib/ReactNativeComponentTree.js +66 -0
- package/lib/ReactNativeContainerInfo.js +21 -0
- package/lib/ReactNativeDOMIDOperations.js +83 -0
- package/lib/ReactNativeDefaultInjection.js +96 -0
- package/lib/ReactNativeEventEmitter.js +188 -0
- package/lib/ReactNativeGlobalResponderHandler.js +25 -0
- package/lib/ReactNativeMount.js +190 -0
- package/lib/ReactNativePropRegistry.js +52 -0
- package/lib/ReactNativeReconcileTransaction.js +100 -0
- package/lib/ReactNativeTagHandles.js +54 -0
- package/lib/ReactNativeTextComponent.js +70 -0
- package/lib/ReactNativeTreeTraversal.js +127 -0
- package/lib/ReactVersion.js +1 -1
- package/lib/TouchHistoryMath.js +99 -0
- package/lib/createReactNativeComponentClass.js +42 -0
- package/lib/findNodeHandle.js +89 -0
- package/package.json +1 -1
- package/lib/ReactDOM.native.js +0 -12
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNativeEventEmitter
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
15
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
16
|
+
var ReactEventEmitterMixin = require('./ReactEventEmitterMixin');
|
|
17
|
+
var ReactNativeComponentTree = require('./ReactNativeComponentTree');
|
|
18
|
+
var ReactNativeTagHandles = require('./ReactNativeTagHandles');
|
|
19
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
20
|
+
var EventConstants = require('./EventConstants');
|
|
21
|
+
|
|
22
|
+
var merge = require('merge');
|
|
23
|
+
var warning = require('fbjs/lib/warning');
|
|
24
|
+
|
|
25
|
+
var topLevelTypes = EventConstants.topLevelTypes;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Version of `ReactBrowserEventEmitter` that works on the receiving side of a
|
|
29
|
+
* serialized worker boundary.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// Shared default empty native event - conserve memory.
|
|
33
|
+
var EMPTY_NATIVE_EVENT = {};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Selects a subsequence of `Touch`es, without destroying `touches`.
|
|
37
|
+
*
|
|
38
|
+
* @param {Array<Touch>} touches Deserialized touch objects.
|
|
39
|
+
* @param {Array<number>} indices Indices by which to pull subsequence.
|
|
40
|
+
* @return {Array<Touch>} Subsequence of touch objects.
|
|
41
|
+
*/
|
|
42
|
+
var touchSubsequence = function (touches, indices) {
|
|
43
|
+
var ret = [];
|
|
44
|
+
for (var i = 0; i < indices.length; i++) {
|
|
45
|
+
ret.push(touches[indices[i]]);
|
|
46
|
+
}
|
|
47
|
+
return ret;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* TODO: Pool all of this.
|
|
52
|
+
*
|
|
53
|
+
* Destroys `touches` by removing touch objects at indices `indices`. This is
|
|
54
|
+
* to maintain compatibility with W3C touch "end" events, where the active
|
|
55
|
+
* touches don't include the set that has just been "ended".
|
|
56
|
+
*
|
|
57
|
+
* @param {Array<Touch>} touches Deserialized touch objects.
|
|
58
|
+
* @param {Array<number>} indices Indices to remove from `touches`.
|
|
59
|
+
* @return {Array<Touch>} Subsequence of removed touch objects.
|
|
60
|
+
*/
|
|
61
|
+
var removeTouchesAtIndices = function (touches, indices) {
|
|
62
|
+
var rippedOut = [];
|
|
63
|
+
// use an unsafe downcast to alias to nullable elements,
|
|
64
|
+
// so we can delete and then compact.
|
|
65
|
+
var temp = touches;
|
|
66
|
+
for (var i = 0; i < indices.length; i++) {
|
|
67
|
+
var index = indices[i];
|
|
68
|
+
rippedOut.push(touches[index]);
|
|
69
|
+
temp[index] = null;
|
|
70
|
+
}
|
|
71
|
+
var fillAt = 0;
|
|
72
|
+
for (var j = 0; j < temp.length; j++) {
|
|
73
|
+
var cur = temp[j];
|
|
74
|
+
if (cur !== null) {
|
|
75
|
+
temp[fillAt++] = cur;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
temp.length = fillAt;
|
|
79
|
+
return rippedOut;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* `ReactNativeEventEmitter` is used to attach top-level event listeners. For example:
|
|
84
|
+
*
|
|
85
|
+
* ReactNativeEventEmitter.putListener('myID', 'onClick', myFunction);
|
|
86
|
+
*
|
|
87
|
+
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
|
|
88
|
+
*
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, {
|
|
92
|
+
|
|
93
|
+
registrationNames: EventPluginRegistry.registrationNameModules,
|
|
94
|
+
|
|
95
|
+
putListener: EventPluginHub.putListener,
|
|
96
|
+
|
|
97
|
+
getListener: EventPluginHub.getListener,
|
|
98
|
+
|
|
99
|
+
deleteListener: EventPluginHub.deleteListener,
|
|
100
|
+
|
|
101
|
+
deleteAllListeners: EventPluginHub.deleteAllListeners,
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Internal version of `receiveEvent` in terms of normalized (non-tag)
|
|
105
|
+
* `rootNodeID`.
|
|
106
|
+
*
|
|
107
|
+
* @see receiveEvent.
|
|
108
|
+
*
|
|
109
|
+
* @param {rootNodeID} rootNodeID React root node ID that event occurred on.
|
|
110
|
+
* @param {TopLevelType} topLevelType Top level type of event.
|
|
111
|
+
* @param {object} nativeEventParam Object passed from native.
|
|
112
|
+
*/
|
|
113
|
+
_receiveRootNodeIDEvent: function (rootNodeID, topLevelType, nativeEventParam) {
|
|
114
|
+
var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT;
|
|
115
|
+
var inst = ReactNativeComponentTree.getInstanceFromNode(rootNodeID);
|
|
116
|
+
if (!inst) {
|
|
117
|
+
// If the original instance is already gone, we don't have to dispatch
|
|
118
|
+
// any events.
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
ReactUpdates.batchedUpdates(function () {
|
|
122
|
+
ReactNativeEventEmitter.handleTopLevel(topLevelType, inst, nativeEvent, nativeEvent.target);
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Publicly exposed method on module for native objc to invoke when a top
|
|
128
|
+
* level event is extracted.
|
|
129
|
+
* @param {rootNodeID} rootNodeID React root node ID that event occurred on.
|
|
130
|
+
* @param {TopLevelType} topLevelType Top level type of event.
|
|
131
|
+
* @param {object} nativeEventParam Object passed from native.
|
|
132
|
+
*/
|
|
133
|
+
receiveEvent: function (tag, topLevelType, nativeEventParam) {
|
|
134
|
+
var rootNodeID = tag;
|
|
135
|
+
ReactNativeEventEmitter._receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam);
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Simple multi-wrapper around `receiveEvent` that is intended to receive an
|
|
140
|
+
* efficient representation of `Touch` objects, and other information that
|
|
141
|
+
* can be used to construct W3C compliant `Event` and `Touch` lists.
|
|
142
|
+
*
|
|
143
|
+
* This may create dispatch behavior that differs than web touch handling. We
|
|
144
|
+
* loop through each of the changed touches and receive it as a single event.
|
|
145
|
+
* So two `touchStart`/`touchMove`s that occur simultaneously are received as
|
|
146
|
+
* two separate touch event dispatches - when they arguably should be one.
|
|
147
|
+
*
|
|
148
|
+
* This implementation reuses the `Touch` objects themselves as the `Event`s
|
|
149
|
+
* since we dispatch an event for each touch (though that might not be spec
|
|
150
|
+
* compliant). The main purpose of reusing them is to save allocations.
|
|
151
|
+
*
|
|
152
|
+
* TODO: Dispatch multiple changed touches in one event. The bubble path
|
|
153
|
+
* could be the first common ancestor of all the `changedTouches`.
|
|
154
|
+
*
|
|
155
|
+
* One difference between this behavior and W3C spec: cancelled touches will
|
|
156
|
+
* not appear in `.touches`, or in any future `.touches`, though they may
|
|
157
|
+
* still be "actively touching the surface".
|
|
158
|
+
*
|
|
159
|
+
* Web desktop polyfills only need to construct a fake touch event with
|
|
160
|
+
* identifier 0, also abandoning traditional click handlers.
|
|
161
|
+
*/
|
|
162
|
+
receiveTouches: function (eventTopLevelType, touches, changedIndices) {
|
|
163
|
+
var changedTouches = eventTopLevelType === topLevelTypes.topTouchEnd || eventTopLevelType === topLevelTypes.topTouchCancel ? removeTouchesAtIndices(touches, changedIndices) : touchSubsequence(touches, changedIndices);
|
|
164
|
+
|
|
165
|
+
for (var jj = 0; jj < changedTouches.length; jj++) {
|
|
166
|
+
var touch = changedTouches[jj];
|
|
167
|
+
// Touch objects can fulfill the role of `DOM` `Event` objects if we set
|
|
168
|
+
// the `changedTouches`/`touches`. This saves allocations.
|
|
169
|
+
touch.changedTouches = changedTouches;
|
|
170
|
+
touch.touches = touches;
|
|
171
|
+
var nativeEvent = touch;
|
|
172
|
+
var rootNodeID = null;
|
|
173
|
+
var target = nativeEvent.target;
|
|
174
|
+
if (target !== null && target !== undefined) {
|
|
175
|
+
if (target < ReactNativeTagHandles.tagsStartAt) {
|
|
176
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
177
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'A view is reporting that a touch occured on tag zero.') : void 0;
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
rootNodeID = target;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
ReactNativeEventEmitter._receiveRootNodeIDEvent(rootNodeID, eventTopLevelType, nativeEvent);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
module.exports = ReactNativeEventEmitter;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNativeGlobalResponderHandler
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var UIManager = require('UIManager');
|
|
14
|
+
|
|
15
|
+
var ReactNativeGlobalResponderHandler = {
|
|
16
|
+
onChange: function (from, to, blockNativeResponder) {
|
|
17
|
+
if (to !== null) {
|
|
18
|
+
UIManager.setJSResponder(to._rootNodeID, blockNativeResponder);
|
|
19
|
+
} else {
|
|
20
|
+
UIManager.clearJSResponder();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = ReactNativeGlobalResponderHandler;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNativeMount
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
var ReactNativeContainerInfo = require('./ReactNativeContainerInfo');
|
|
16
|
+
var ReactNativeTagHandles = require('./ReactNativeTagHandles');
|
|
17
|
+
var ReactPerf = require('./ReactPerf');
|
|
18
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
19
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
20
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
21
|
+
var UIManager = require('UIManager');
|
|
22
|
+
|
|
23
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
24
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
25
|
+
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Temporary (?) hack so that we can store all top-level pending updates on
|
|
29
|
+
* composites instead of having to worry about different types of components
|
|
30
|
+
* here.
|
|
31
|
+
*/
|
|
32
|
+
var TopLevelWrapper = function () {};
|
|
33
|
+
TopLevelWrapper.prototype.isReactComponent = {};
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
TopLevelWrapper.displayName = 'TopLevelWrapper';
|
|
36
|
+
}
|
|
37
|
+
TopLevelWrapper.prototype.render = function () {
|
|
38
|
+
// this.props is actually a ReactElement
|
|
39
|
+
return this.props;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Mounts this component and inserts it into the DOM.
|
|
44
|
+
*
|
|
45
|
+
* @param {ReactComponent} componentInstance The instance to mount.
|
|
46
|
+
* @param {number} rootID ID of the root node.
|
|
47
|
+
* @param {number} containerTag container element to mount into.
|
|
48
|
+
* @param {ReactReconcileTransaction} transaction
|
|
49
|
+
*/
|
|
50
|
+
function mountComponentIntoNode(componentInstance, containerTag, transaction) {
|
|
51
|
+
var markup = ReactReconciler.mountComponent(componentInstance, transaction, null, ReactNativeContainerInfo(containerTag), emptyObject);
|
|
52
|
+
componentInstance._renderedComponent._topLevelWrapper = componentInstance;
|
|
53
|
+
ReactNativeMount._mountImageIntoNode(markup, containerTag);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Batched mount.
|
|
58
|
+
*
|
|
59
|
+
* @param {ReactComponent} componentInstance The instance to mount.
|
|
60
|
+
* @param {number} rootID ID of the root node.
|
|
61
|
+
* @param {number} containerTag container element to mount into.
|
|
62
|
+
*/
|
|
63
|
+
function batchedMountComponentIntoNode(componentInstance, containerTag) {
|
|
64
|
+
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
|
|
65
|
+
transaction.perform(mountComponentIntoNode, null, componentInstance, containerTag, transaction);
|
|
66
|
+
ReactUpdates.ReactReconcileTransaction.release(transaction);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* As soon as `ReactMount` is refactored to not rely on the DOM, we can share
|
|
71
|
+
* code between the two. For now, we'll hard code the ID logic.
|
|
72
|
+
*/
|
|
73
|
+
var ReactNativeMount = {
|
|
74
|
+
_instancesByContainerID: {},
|
|
75
|
+
|
|
76
|
+
// these two functions are needed by React Devtools
|
|
77
|
+
findNodeHandle: require('./findNodeHandle'),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {ReactComponent} instance Instance to render.
|
|
81
|
+
* @param {containerTag} containerView Handle to native view tag
|
|
82
|
+
*/
|
|
83
|
+
renderComponent: function (nextElement, containerTag, callback) {
|
|
84
|
+
var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
|
|
85
|
+
|
|
86
|
+
var topRootNodeID = containerTag;
|
|
87
|
+
var prevComponent = ReactNativeMount._instancesByContainerID[topRootNodeID];
|
|
88
|
+
if (prevComponent) {
|
|
89
|
+
var prevWrappedElement = prevComponent._currentElement;
|
|
90
|
+
var prevElement = prevWrappedElement.props;
|
|
91
|
+
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
92
|
+
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement);
|
|
93
|
+
if (callback) {
|
|
94
|
+
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
|
|
95
|
+
}
|
|
96
|
+
return prevComponent;
|
|
97
|
+
} else {
|
|
98
|
+
ReactNativeMount.unmountComponentAtNode(containerTag);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!ReactNativeTagHandles.reactTagIsNativeTopRootID(containerTag)) {
|
|
103
|
+
console.error('You cannot render into anything but a top root');
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
ReactNativeTagHandles.assertRootTag(containerTag);
|
|
108
|
+
|
|
109
|
+
var instance = instantiateReactComponent(nextWrappedElement);
|
|
110
|
+
ReactNativeMount._instancesByContainerID[containerTag] = instance;
|
|
111
|
+
|
|
112
|
+
// The initial render is synchronous but any updates that happen during
|
|
113
|
+
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
114
|
+
// according to the current batching strategy.
|
|
115
|
+
|
|
116
|
+
ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, instance, containerTag);
|
|
117
|
+
var component = instance.getPublicInstance();
|
|
118
|
+
if (callback) {
|
|
119
|
+
callback.call(component);
|
|
120
|
+
}
|
|
121
|
+
return component;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param {View} view View tree image.
|
|
126
|
+
* @param {number} containerViewID View to insert sub-view into.
|
|
127
|
+
*/
|
|
128
|
+
_mountImageIntoNode: ReactPerf.measure(
|
|
129
|
+
// FIXME(frantic): #4441289 Hack to avoid modifying react-tools
|
|
130
|
+
'ReactComponentBrowserEnvironment', 'mountImageIntoNode', function (mountImage, containerID) {
|
|
131
|
+
// Since we now know that the `mountImage` has been mounted, we can
|
|
132
|
+
// mark it as such.
|
|
133
|
+
var childTag = mountImage;
|
|
134
|
+
UIManager.setChildren(containerID, [childTag]);
|
|
135
|
+
}),
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Standard unmounting of the component that is rendered into `containerID`,
|
|
139
|
+
* but will also execute a command to remove the actual container view
|
|
140
|
+
* itself. This is useful when a client is cleaning up a React tree, and also
|
|
141
|
+
* knows that the container will no longer be needed. When executing
|
|
142
|
+
* asynchronously, it's easier to just have this method be the one that calls
|
|
143
|
+
* for removal of the view.
|
|
144
|
+
*/
|
|
145
|
+
unmountComponentAtNodeAndRemoveContainer: function (containerTag) {
|
|
146
|
+
ReactNativeMount.unmountComponentAtNode(containerTag);
|
|
147
|
+
// call back into native to remove all of the subviews from this container
|
|
148
|
+
UIManager.removeRootView(containerTag);
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Unmount component at container ID by iterating through each child component
|
|
153
|
+
* that has been rendered and unmounting it. There should just be one child
|
|
154
|
+
* component at this time.
|
|
155
|
+
*/
|
|
156
|
+
unmountComponentAtNode: function (containerTag) {
|
|
157
|
+
if (!ReactNativeTagHandles.reactTagIsNativeTopRootID(containerTag)) {
|
|
158
|
+
console.error('You cannot render into anything but a top root');
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var instance = ReactNativeMount._instancesByContainerID[containerTag];
|
|
163
|
+
if (!instance) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
ReactNativeMount.unmountComponentFromNode(instance, containerTag);
|
|
167
|
+
delete ReactNativeMount._instancesByContainerID[containerTag];
|
|
168
|
+
return true;
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Unmounts a component and sends messages back to iOS to remove its subviews.
|
|
173
|
+
*
|
|
174
|
+
* @param {ReactComponent} instance React component instance.
|
|
175
|
+
* @param {string} containerID ID of container we're removing from.
|
|
176
|
+
* @final
|
|
177
|
+
* @internal
|
|
178
|
+
* @see {ReactNativeMount.unmountComponentAtNode}
|
|
179
|
+
*/
|
|
180
|
+
unmountComponentFromNode: function (instance, containerID) {
|
|
181
|
+
// Call back into native to remove all of the subviews from this container
|
|
182
|
+
ReactReconciler.unmountComponent(instance);
|
|
183
|
+
UIManager.removeSubviewsFromContainerWithID(containerID);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
ReactNativeMount.renderComponent = ReactPerf.measure('ReactMount', '_renderNewRootComponent', ReactNativeMount.renderComponent);
|
|
189
|
+
|
|
190
|
+
module.exports = ReactNativeMount;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNativePropRegistry
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
|
|
16
|
+
var objects = {};
|
|
17
|
+
var uniqueID = 1;
|
|
18
|
+
var emptyObject = {};
|
|
19
|
+
|
|
20
|
+
var ReactNativePropRegistry = function () {
|
|
21
|
+
function ReactNativePropRegistry() {
|
|
22
|
+
_classCallCheck(this, ReactNativePropRegistry);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ReactNativePropRegistry.register = function register(object) {
|
|
26
|
+
var id = ++uniqueID;
|
|
27
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
+
Object.freeze(object);
|
|
29
|
+
}
|
|
30
|
+
objects[id] = object;
|
|
31
|
+
return id;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
ReactNativePropRegistry.getByID = function getByID(id) {
|
|
35
|
+
if (!id) {
|
|
36
|
+
// Used in the style={[condition && id]} pattern,
|
|
37
|
+
// we want it to be a no-op when the value is false or null
|
|
38
|
+
return emptyObject;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var object = objects[id];
|
|
42
|
+
if (!object) {
|
|
43
|
+
console.warn('Invalid style with id `' + id + '`. Skipping ...');
|
|
44
|
+
return emptyObject;
|
|
45
|
+
}
|
|
46
|
+
return object;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return ReactNativePropRegistry;
|
|
50
|
+
}();
|
|
51
|
+
|
|
52
|
+
module.exports = ReactNativePropRegistry;
|