forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for next React Native sync with new instance format (facebook…
…#36438) Summary: Pull Request resolved: facebook#36438 This makes the `react-native` repository compatible with the next sync from react after the changes in facebook/react#26321 land. That PR is changing the format of the Fabric instance and we have a few instances where we assume the internal structure of that instance in the repository. Changelog: [internal] Reviewed By: yungsters Differential Revision: D43980374 fbshipit-source-id: 8b716f2e4a99ac0312bfe6927f364429e94c9574
- Loading branch information
1 parent
ec09561
commit c51fe74
Showing
5 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow strict | ||
*/ | ||
|
||
export function isPublicInstance(maybeInstance: mixed): boolean { | ||
return ( | ||
maybeInstance != null && | ||
// TODO: implement a better check (maybe using instanceof) when the instance is defined in the React Native repository. | ||
(maybeInstance.__nativeTag != null || | ||
// TODO: remove this check when syncing the new version of the renderer from React to React Native. | ||
isLegacyFabricInstance(maybeInstance)) | ||
); | ||
} | ||
|
||
function isLegacyFabricInstance(maybeInstance: mixed): boolean { | ||
/* eslint-disable dot-notation */ | ||
return ( | ||
maybeInstance != null && | ||
// $FlowExpectedError[incompatible-use] | ||
maybeInstance['_internalInstanceHandle'] != null && | ||
maybeInstance['_internalInstanceHandle'].stateNode != null && | ||
maybeInstance['_internalInstanceHandle'].stateNode.canonical != null | ||
); | ||
} |