From c33954c80d94e1d8e8262f3cdcaf28bb0b7ac045 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Wed, 15 Jan 2025 06:11:21 -0800 Subject: [PATCH] Migrate rn-tester/IntegrationTests/GlobalEvalWithSourceUrlTest.js to function components (#48695) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48695 As per title. Changelog: [Internal] Reviewed By: rshest Differential Revision: D68152232 fbshipit-source-id: 918236f8c9789efab9cc43b85e53fa398909808c --- .../GlobalEvalWithSourceUrlTest.js | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/rn-tester/IntegrationTests/GlobalEvalWithSourceUrlTest.js b/packages/rn-tester/IntegrationTests/GlobalEvalWithSourceUrlTest.js index 6b1d83ed765ac4..3dd3a43ca1288c 100644 --- a/packages/rn-tester/IntegrationTests/GlobalEvalWithSourceUrlTest.js +++ b/packages/rn-tester/IntegrationTests/GlobalEvalWithSourceUrlTest.js @@ -12,15 +12,15 @@ import type {ExtendedError} from 'react-native/Libraries/Core/ExtendedError'; -const React = require('react'); -const ReactNative = require('react-native'); -const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack'); -const {View} = ReactNative; +import * as React from 'react'; +import {useEffect} from 'react'; +import {NativeModules, View} from 'react-native'; +import parseErrorStack from 'react-native/Libraries/Core/Devtools/parseErrorStack'; -const {TestModule} = ReactNative.NativeModules; +const {TestModule} = NativeModules; -class GlobalEvalWithSourceUrlTest extends React.Component<{...}> { - componentDidMount(): void { +function GlobalEvalWithSourceUrlTest(): React.Node { + useEffect(() => { if (typeof global.globalEvalWithSourceUrl !== 'function') { throw new Error( 'Expected to find globalEvalWithSourceUrl function on global object but found ' + @@ -75,13 +75,9 @@ class GlobalEvalWithSourceUrlTest extends React.Component<{...}> { ); } TestModule.markTestCompleted(); - } + }, []); - render(): React.Node { - return ; - } + return ; } -GlobalEvalWithSourceUrlTest.displayName = 'GlobalEvalWithSourceUrlTest'; - -module.exports = GlobalEvalWithSourceUrlTest; +export default GlobalEvalWithSourceUrlTest;