Skip to content

Commit

Permalink
Add Fabric Interop constants example (#36417)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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: 1d4b630d45d21904c53d85b97607ebb7fb8a62fc
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Mar 10, 2023
1 parent c005830 commit a5866ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ @interface RNTMyLegacyNativeViewManager : RCTViewManager

@implementation RNTMyLegacyNativeViewManager

+ (BOOL)requiresMainQueueSetup
{
return NO;
}

RCT_EXPORT_MODULE()

RCT_REMAP_VIEW_PROPERTY(color, backgroundColor, UIColor)
Expand All @@ -31,4 +36,8 @@ - (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 a5866ca

Please sign in to comment.