Files
react-native/packages/rn-tester/IntegrationTests/LoggingTestModule.js
T
Iwo Plaza 135277ace1 Migrate AppState and BatchedBridge files to use export syntax. (#48737)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48737

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling.

## This diff
- Updates files in Libraries/AppState and Libraries/BatchedBridge to use `export` syntax
  - `export default` for qualified objects, many `export` statements for collections (determined by how it's imported)
- Appends `.default` to requires of the changed files.
- Updates Jest mocks.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/BatchedBridge` and `Libraries/AppState` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: robhogan

Differential Revision: D68275767

fbshipit-source-id: 97dc84c04a8dd9c9022e53fc4595302efc848338
2025-01-17 11:19:43 -08:00

42 lines
943 B
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const invariant = require('invariant');
const BatchedBridge =
require('react-native/Libraries/BatchedBridge/BatchedBridge').default;
const LoggingTestModule = {
logToConsole: function (str) {
console.log(str);
},
logToConsoleAfterWait: function (str, timeout_ms) {
setTimeout(function () {
console.log(str);
}, timeout_ms);
},
warning: function (str) {
console.warn(str);
},
invariant: function (str) {
invariant(false, str);
},
logErrorToConsole: function (str) {
console.error(str);
},
throwError: function (str) {
throw new Error(str);
},
};
BatchedBridge.registerCallableModule('LoggingTestModule', LoggingTestModule);
module.exports = LoggingTestModule;