clipboard
clipboard copied to clipboard
setString doesn't work
Environment
Expo CLI 3.27.4 environment info:
System:
OS: Windows 10 10.0.20206
Binaries:
Node: 14.10.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.2 - F:\Programy\yarm\bin\yarn.CMD
npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
npmPackages:
expo: ^38.0.10 => 38.0.10
react: ^16.11.0 => 16.11.0
react-dom: ^16.11.0 => 16.11.0
react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2
react-native-web: ^0.11.7 => 0.11.7
Expo Workflow: managed
Platforms
iOS, not sure about Android, it is possibly (and probably) also affected.
Versions
- iOS: 14 beta 7
- react-native: 0.62
- react: 16.11.0
Description
When trying to set a string to the clipboard, it is denied and errors out:
TypeError: null is not an object (evaluating 'NativeClipboard_1.setString')
Reproducible Demo
Clipboard.setString("Test"); // Errors out
I'm getting the same issue on iOS 13.6, react-native 0.59 - any workaround?
I have the same issue (expo SDK 38).
I ended up reverting to clipboard from react-native for now.
import { Clipboard } from 'react-native'
updated:
You can use import * as Clipboard from 'expo-clipboard'
now. I'm usgin SDK 43.
Seeing the same issue...any word on what causes this? You see it with the useHook
too except you will see it here:
getString: function () {
return NativeClipboard_1.default.getString();
}
I had the same problem on Android. Solved uninstalling the app and reinstalling it.
Same here on Expo SDK 38 + 39 and @react-native-community/clipboard: ^1.2.3
Solved it by using @foloinfo solution by using import { Clipboard } from 'react-native'
Same here on Expo SDK 38 + 39 and @react-native-community/clipboard: ^1.2.3
Solved it by using @foloinfo solution by using
import { Clipboard } from 'react-native'
The only issue with that method is it has been declared as deprecated even though it still works. Also, it points them here to where things are broken...
@afreeland Yes, but it's a temporary solution, and until it gets fixed, we are stuck with it😢
currently managed workflow for expo does not support this clipboard module.
Please continue using import {Clipboard} from 'react-native'
for now until the support is added to expo.
This module should work for bare workflow of expo and regular react-native via react-native-cli sorry about the inconvenience!
Hi, Need to release the app so cannot go with deprecated one, please fix this issue ASAP :pray:
Any update on this issue??... I'm also facing the same issue but only on iOS. It's working correctly on android.
There is honestly nothing I can do about using this package on a managed workflow of expo, as managed workflow of expo has predetermined sets of native modules it can use and this package isn't one of them.
Please use import {Clipboard} from 'react-native'
for managed workflow of expo.
Any solutions?
I have the same issue,
I solved it this way:
import {useClipboard} from '@react-native-community/clipboard';
I had the same issue with Android.
Weird enough I had to do a pod install:
cd ios && pod install && cd ../
after that, I ran react-native run-android
and it worked.
I had the same problem on Android. Solved uninstalling the app and reinstalling it.
This is works for me. But is it safe for production update? I mean when we just add this library and deploy this new updated app to play store
The same problem with v1.5.1 on android and web app. I tried to use Clipboard.setString and hook realization, both have this problem.
Facing the same issue...Any update on this?
For expo users, please use the expo-clipboard
module provided by expo.
For non-expo users, if you're facing the issue, please provide a minimal repository that can reproduce the issue.
I solved it
cd ios && pod install
don't think it's the library issue
try to clean your project(reset metro bundler cache, delete build folder) and do fresh npm install
and pod install
.
That worked for me!
don't think it's the library issue try to clean your project(reset metro bundler cache, delete build folder) and do fresh
npm install
andpod install
. That worked for me!
Just solved the issue by restart the metro bundler. i.e. re-run react-native start
. Thank you :)
For android use this way: https://github.com/react-native-clipboard/clipboard/issues/80#issuecomment-759605515
I did these, but problem is not resolved:
- rm -rf node_modules && npm install
- cd android && ./gradlew clean
- cd ios && pod install && cd ..
I Have this error: TypeError: Cannot read property 'setString' of null
Same issue here, using deprecated version from "react-native" temporarily solves my issue.
import { Clipboard } from "react-native"
I solved it by reinstalling the app
this was solved for me by restarting metro.. ( i was running on IOS thought) i closed the simulator and metro and restarted again using npx react-native run-ios
and it finally worked after hours of trying to figure it out!
FYI, im not using expo though.
A project clean in xcode and npm start -reset-cache
did it for me.
Did you all run pod install
before building ? :P This package worked for me on the first try. Didn't need to clean XCode build cache, or npm cache, or removing the app.
the solution is as simple as:
import Clipboard from '@react-native-community/clipboard'
instead of
import { Clipboard } from '@react-native-community/clipboard'
the same issue was fixed by manually linking the package react-native link @react-native-clipboard/clipboard
. I am ushing RN0.60+ in the dox it says it will auto-link but for me, I have to do it manually and it worked