Skip to content

Commit

Permalink
Update React Native shims to use export syntax (#31426)
Browse files Browse the repository at this point in the history
## Summary

I'm working to get the main `react-native` package parsable by modern
Flow tooling (both `flow-bundler`, `flow-api-translator`), and one
blocker is legacy `module.exports` syntax. This diff updates files which
are [synced to
`react-native`](https://github.com/facebook/react-native/tree/main/packages/react-native/Libraries/Renderer/shims)
from this repo.

## How did you test this change?

Files were pasted into `react-native-github` under fbsource, where Flow
validates ✅.
  • Loading branch information
huntie authored Nov 7, 2024
1 parent 682a103 commit 5c56b87
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scripts/rollup/shims/react-native/ReactFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {BatchedBridge} from 'react-native/Libraries/ReactPrivate/ReactNativePriv

import type {ReactFabricType} from './ReactNativeTypes';

let ReactFabric;
let ReactFabric: ReactFabricType;

if (__DEV__) {
ReactFabric = require('../implementations/ReactFabric-dev');
Expand All @@ -29,4 +29,4 @@ if (global.RN$Bridgeless !== true) {
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);
}

module.exports = (ReactFabric: ReactFabricType);
export default ReactFabric;
2 changes: 1 addition & 1 deletion scripts/rollup/shims/react-native/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ const ReactFeatureFlags = {
debugRenderPhaseSideEffects: false,
};

module.exports = ReactFeatureFlags;
export default ReactFeatureFlags;
4 changes: 2 additions & 2 deletions scripts/rollup/shims/react-native/ReactNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

import type {ReactNativeType} from './ReactNativeTypes';

let ReactNative;
let ReactNative: ReactNativeType;

if (__DEV__) {
ReactNative = require('../implementations/ReactNativeRenderer-dev');
} else {
ReactNative = require('../implementations/ReactNativeRenderer-prod');
}

module.exports = (ReactNative: ReactNativeType);
export default ReactNative;
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ const createReactNativeComponentClass = function (
return register(name, callback);
};

module.exports = createReactNativeComponentClass;
export default createReactNativeComponentClass;

0 comments on commit 5c56b87

Please sign in to comment.