You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

copyText.native.ts 409B

123456789101112131415161718
  1. import Clipboard from '@react-native-clipboard/clipboard';
  2. /**
  3. * Tries to copy a given text to the clipboard.
  4. * Returns true if the action succeeds.
  5. *
  6. * @param {string} textToCopy - Text to be copied.
  7. * @returns {Promise<boolean>}
  8. */
  9. export function copyText(textToCopy: string) {
  10. try {
  11. Clipboard.setString(textToCopy);
  12. return true;
  13. } catch (e) {
  14. return false;
  15. }
  16. }