-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support findNodeHandle in Fabric (#12573)
This doesn't actually need to share any state because it goes through the instance to the fiber structure. Since Fabric is on the same version as RN, calling it on either renderer works.
- Loading branch information
1 parent
6bf2797
commit bc753a7
Showing
4 changed files
with
58 additions
and
27 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
52 changes: 52 additions & 0 deletions
52
packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js
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,52 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
* @jest-environment node | ||
*/ | ||
|
||
'use strict'; | ||
|
||
let React; | ||
let ReactFabric; | ||
let ReactNative; | ||
let createReactNativeComponentClass; | ||
|
||
describe('ReactFabric', () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
ReactNative = require('react-native-renderer'); | ||
jest.resetModules(); | ||
jest.mock('shared/ReactFeatureFlags', () => | ||
require('shared/forks/ReactFeatureFlags.native-fabric'), | ||
); | ||
|
||
React = require('react'); | ||
ReactFabric = require('react-native-renderer/fabric'); | ||
createReactNativeComponentClass = require('../createReactNativeComponentClass') | ||
.default; | ||
}); | ||
|
||
it('find Fabric nodes with the RN renderer', () => { | ||
const View = createReactNativeComponentClass('View', () => ({ | ||
validAttributes: {title: true}, | ||
uiViewClassName: 'View', | ||
})); | ||
|
||
let ref = React.createRef(); | ||
|
||
class Component extends React.Component { | ||
render() { | ||
return <View title="foo" />; | ||
} | ||
} | ||
|
||
ReactFabric.render(<Component ref={ref} />, 11); | ||
|
||
let handle = ReactNative.findNodeHandle(ref.current); | ||
expect(handle).toBe(2); | ||
}); | ||
}); |
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