SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

Use lazy TurboModule lookup for Clipboard in LogBoxInspector (#56199)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56199

D95277489 added a Copy button to LogBoxInspector that imports
`Clipboard`, which calls `TurboModuleRegistry.getEnforcing('Clipboard')`
at module load time. In environments where the native Clipboard module
is not available (e.g., Fantom integration tests), this throws and
crashes the entire test file (`LogBox-itest.fb.js`).

Replace the static `Clipboard` import with a lazy
`TurboModuleRegistry.get()` call at invocation time, which returns
`null` when the module is unavailable instead of throwing.

Changelog: [internal][fixed][LogBox] - Fix crash when Clipboard module is unavailable

Reviewed By: NickGerleman

Differential Revision: D97008263

fbshipit-source-id: 5720ff8fdeb3f187aa7be77b13dc839c02469751
S
Sean Tarzy committed
a06153c52aa6bbc415fa5a66d4dc6aba223fbce1
Parent: 0b1def9
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com> on 3/25/2026, 12:43:56 AM