mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Fix setJSResponder Nodes crash
Summary: Nodes crashed when setJSResponder was called on a virtual (non-View) node, because a View could not be found using that react tag. The solution is two fold - first, to figure out the View parent and pass that to setJSResponder in addition to that of the virtual tag. Secondly, we weren't mounting views that had animation properties (transform, for example) to Views, which caused related code to fail. Reviewed By: sriramramani Differential Revision: D3301310
This commit is contained in:
@@ -465,10 +465,18 @@ public class FlatUIImplementation extends UIImplementation {
|
||||
while (node.isVirtual()) {
|
||||
node = node.getParent();
|
||||
}
|
||||
int tag = node.getReactTag();
|
||||
|
||||
// if the node in question doesn't mount to a View, find the first parent that does mount to
|
||||
// a View. without this, we'll crash when we try to set the JSResponder, since part of that
|
||||
// is to find the parent view and ask it to not intercept touch events.
|
||||
while (node instanceof FlatShadowNode && !((FlatShadowNode) node).mountsToView()) {
|
||||
node = node.getParent();
|
||||
}
|
||||
|
||||
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
|
||||
operationsQueue.enqueueSetJSResponder(
|
||||
node.getReactTag(),
|
||||
node == null ? tag : node.getReactTag(),
|
||||
possiblyVirtualReactTag,
|
||||
blockNativeResponder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user