Skip to content

Commit

Permalink
UIManager: Delete replaceExistingNonRootView (facebook#42065)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#42065

We should delete from UIManager:
- There are no usages of this api at Meta.
- The only usages found on GitHub are from old forks of React Native: [Github search](https://github.com/search?q=replaceExistingNonRootView+language%3AJavaScript&type=code&p=5&l=JavaScript)

Changelog: [Android][Removed] - Delete UIManager.replaceExistingNonRootView

Reviewed By: sammy-SC

Differential Revision: D52345872

fbshipit-source-id: b61e49731c68fff1f9c4223924a95b4d1e4763c1
  • Loading branch information
RSNara authored and gokul1099 committed Jan 17, 2024
1 parent edb447f commit 1e3a184
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,6 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
): void => {
raiseSoftError('configureNextLayoutAnimation');
},
replaceExistingNonRootView: (
reactTag: ?number,
newReactTag: ?number,
): void => {
raiseSoftError('replaceExistingNonRootView');
},
};

if (getUIManagerConstants) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export interface Spec extends TurboModule {
callback: () => void, // check what is returned here
errorCallback: (error: Object) => void,
) => void;
+replaceExistingNonRootView: (
reactTag: ?number,
newReactTag: ?number,
) => void;
+setChildren: (containerTag: ?number, reactTags: Array<number>) => void;
+manageChildren: (
containerTag: ?number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ module.exports = [
'measureLayout',
'measureLayoutRelativeToParent',
'removeRootView',
'replaceExistingNonRootView',
'sendAccessibilityEvent',
'setChildren',
'setJSResponder',
Expand Down
25 changes: 0 additions & 25 deletions packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -820,31 +820,6 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
}];
}

RCT_EXPORT_METHOD(replaceExistingNonRootView : (nonnull NSNumber *)reactTag withView : (nonnull NSNumber *)newReactTag)
{
RCTLogWarn(
@"RCTUIManager.replaceExistingNonRootView method is deprecated and it will not be implemented in newer versions of RN (Fabric) - T47686450");
RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
RCTAssert(shadowView != nil, @"shadowView (for ID %@) not found", reactTag);

RCTShadowView *superShadowView = shadowView.superview;
if (!superShadowView) {
RCTAssert(NO, @"shadowView super (of ID %@) not found", reactTag);
return;
}

NSUInteger indexOfView = [superShadowView.reactSubviews indexOfObjectIdenticalTo:shadowView];
RCTAssert(indexOfView != NSNotFound, @"View's superview doesn't claim it as subview (id %@)", reactTag);
NSArray<NSNumber *> *removeAtIndices = @[ @(indexOfView) ];
NSArray<NSNumber *> *addTags = @[ newReactTag ];
[self manageChildren:superShadowView.reactTag
moveFromIndices:nil
moveToIndices:nil
addChildReactTags:addTags
addAtIndices:removeAtIndices
removeAtIndices:removeAtIndices];
}

RCT_EXPORT_METHOD(setChildren : (nonnull NSNumber *)containerTag reactTags : (NSArray<NSNumber *> *)reactTags)
{
RCTSetChildren(containerTag, reactTags, (NSDictionary<NSNumber *, id<RCTComponent>> *)_shadowViewRegistry);
Expand Down
2 changes: 0 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -4861,7 +4861,6 @@ public class com/facebook/react/uimanager/UIImplementation {
public fun removeRootShadowNode (I)V
public fun removeRootView (I)V
protected final fun removeShadowNode (Lcom/facebook/react/uimanager/ReactShadowNode;)V
public fun replaceExistingNonRootView (II)V
public fun resolveRootTagFromReactTag (I)I
public final fun resolveShadowNode (I)Lcom/facebook/react/uimanager/ReactShadowNode;
protected final fun resolveViewManager (Ljava/lang/String;)Lcom/facebook/react/uimanager/ViewManager;
Expand Down Expand Up @@ -4950,7 +4949,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun removeRootView (I)V
public fun removeUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun removeUIManagerListener (Lcom/facebook/react/uimanager/UIManagerModuleListener;)V
public fun replaceExistingNonRootView (II)V
public fun resolveCustomDirectEventName (Ljava/lang/String;)Ljava/lang/String;
public fun resolveRootTagFromReactTag (I)I
public fun resolveView (I)Landroid/view/View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,19 +486,6 @@ public void setChildren(int viewTag, ReadableArray childrenTags) {
mUIImplementation.setChildren(viewTag, childrenTags);
}

/**
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
* This resolves to a simple {@link #manageChildren} call, but React doesn't have enough info in
* JS to formulate it itself.
*
* @deprecated This method will not be available in Fabric UIManager class.
*/
@ReactMethod
@Deprecated
public void replaceExistingNonRootView(int oldTag, int newTag) {
mUIImplementation.replaceExistingNonRootView(oldTag, newTag);
}

/**
* Determines the location on screen, width, and height of the given view and returns the values
* via an async callback.
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jest
}),
measure: jest.fn(),
manageChildren: jest.fn(),
replaceExistingNonRootView: jest.fn(),
setChildren: jest.fn(),
updateView: jest.fn(),
AndroidDrawerLayout: {
Expand Down

0 comments on commit 1e3a184

Please sign in to comment.