Skip to content

Commit

Permalink
Add Fabric Interop constants example (facebook#36417)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#36417

This changes adds an example to RNTester to verify that the Interop Layer can process constants in Fabric as it used to do in Paper.

## Changelog:
[iOS][Added] - Add example in the Interop Layer to use constants

Reviewed By: cortinico

Differential Revision: D43911916

fbshipit-source-id: 585669a3c997fc0f60a71789bafa7223ebff5c1c
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Mar 9, 2023
1 parent 1a6715e commit 9c7b411
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ @interface RNTMyLegacyNativeViewManager : RCTViewManager

@implementation RNTMyLegacyNativeViewManager

+(BOOL)requiresMainQueueSetup {
return NO;
}

RCT_EXPORT_MODULE()

RCT_REMAP_VIEW_PROPERTY(color, backgroundColor, UIColor)
Expand All @@ -31,4 +35,10 @@ - (UIView *)view
return view;
}

- (NSDictionary *)constantsToExport
{
return @{
@"PI": @3.14
};
}
@end
5 changes: 5 additions & 0 deletions packages/rn-tester/NativeComponentExample/js/MyNativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import RNTMyNativeView, {
} from './MyNativeViewNativeComponent';
import RNTMyLegacyNativeView from './MyLegacyViewNativeComponent';
import type {MyNativeViewType} from './MyNativeViewNativeComponent';
import {UIManager} from 'react-native';

const colors = [
'#0000FF',
Expand Down Expand Up @@ -76,6 +77,10 @@ export default function MyNativeView(props: {}): React.Node {
}
/>
<Text>HSBA: {hsba.toString()}</Text>
<Text>
Constants From Interop Layer:{' '}
{UIManager.RNTMyLegacyNativeView.Constants.PI}
</Text>
<Button
title="Change Background"
onPress={() => {
Expand Down

0 comments on commit 9c7b411

Please sign in to comment.