clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

getString() never resolves

Open ghost opened this issue 4 years ago • 3 comments

Environment

info Fetching system and libraries information...
System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 2.66 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2021.12.20.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 26, 27, 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 32.0.0
      System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7583922
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_275 - /Users/xxx/.sdkman/candidates/java/current/bin/javac
    Python: 2.7.18 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: 6.1.0 => 6.1.0
    react: 17.0.2 => 17.0.2
    react-native: 0.65.1 => 0.65.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

both

Versions

Description

When I call await Clipboard.getString() the promise will not be resolved (ever)

This happens if your metro configuration is:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

If you flip inlineRequires to false, then promise in this library starts working again. Because this is issue only with this package I believe there is some conflict, but for now I do not have deeper knowledge why is that, just reporting it here as it may help someone...

What is interesting though that this repository has the flag turned to true, I believe it will be issue just with "published / build" package.

There is similar issue opened in react-native repo: https://github.com/facebook/react-native/issues/31558

Reproducible Demo

ghost avatar Jan 03 '22 14:01 ghost

inlineRequires: true works fine for me. I'm using RN 0.66.3 and clipboard 1.9.0

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

cristianoccazinsp avatar Jan 12 '22 01:01 cristianoccazinsp

I've been using @react-native-clipboard/clipboard and it's been working great but suddenly I notice today that getString() is now returning empty. And I have not changed this code. Anyone know what is going on?

cam-eo avatar Jan 22 '22 13:01 cam-eo

I had the same problem, I solved it by changing inlineRequires: true to inlineRequires: false

chococrypto avatar Aug 15 '22 15:08 chococrypto