Skip to content

Commit

Permalink
Use UIManagerHelper to access EventDispatcher in ReactViewManager
Browse files Browse the repository at this point in the history
Summary:
ReactViewManager uses the bridge (CatalystInstance) to access the UIManagerModule in its onClick method. This doesn't work in bridgeless mode, so I'm replacing this callsite with the new API, which uses UIManagerHelper + the reactTag to look up the appropriate UIManager (Paper or Fabric), and get the EventDispatcher from that.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21510243

fbshipit-source-id: c2c6111e73c49ca6bf873819db8ece71c66417e4
  • Loading branch information
Emily Janzer authored and facebook-github-bot committed May 12, 2020
1 parent dba5887 commit 6c4224e
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.Spacing;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
Expand Down Expand Up @@ -233,14 +233,12 @@ public void setFocusable(final ReactViewGroup view, boolean focusable) {
new View.OnClickListener() {
@Override
public void onClick(View v) {
UIManagerModule uiManager =
((ReactContext) view.getContext()).getNativeModule(UIManagerModule.class);

if (uiManager == null) {
final EventDispatcher mEventDispatcher =
UIManagerHelper.getEventDispatcherForReactTag(
(ReactContext) view.getContext(), view.getId());
if (mEventDispatcher == null) {
return;
}

final EventDispatcher mEventDispatcher = uiManager.getEventDispatcher();
mEventDispatcher.dispatchEvent(new ViewGroupClickEvent(view.getId()));
}
});
Expand Down

0 comments on commit 6c4224e

Please sign in to comment.