Giter VIP home page Giter VIP logo

Comments (9)

focux avatar focux commented on May 28, 2024 7

For those having this issue, instead of using the useClipboard hook, use the Clipboard object depending on what you want to do. If you use the useClipboard hook, it gets what is in the clipboard when the screen is mounted, however, if you use the Clipboard function, you can read the clipboard only when you need to.

from clipboard.

EricWiener avatar EricWiener commented on May 28, 2024 2

Pre-iOS 14, the way to check clipboard content was to look at the data in it, so this is why you get the notification you pasted from the clipboard. The API for iOS 14 has been updated to allow you to check clipboard content without actually looking at the data (and avoiding the notification).

from clipboard.

filiptronicek avatar filiptronicek commented on May 28, 2024 2

Nice then, I will create an issue, and we'll go from there! @EricWiener

from clipboard.

ghobashy avatar ghobashy commented on May 28, 2024

I'm facing the same issue, is there any solution or workaround for this issue?

from clipboard.

fritzfr avatar fritzfr commented on May 28, 2024

Interesting.

Looking at the recent TikTok news regarding exactly this behaviour, this should better be investigated.

from clipboard.

ghobashy avatar ghobashy commented on May 28, 2024

Actually i found that my issue was not with react native clipboard, it was coming from firebase dynamic links v6.3 once i commented out Firebase/DynamicLinks dependency in my PodFile it went away.

Hope that helps.

from clipboard.

filiptronicek avatar filiptronicek commented on May 28, 2024

Pre-iOS 14, the way to check clipboard content was to look at the data in it, so this is why you get the notification you pasted from the clipboard. The API for iOS 14 has been updated to allow you to check clipboard content without actually looking at the data (and avoiding the notification).

@EricWiener is this implemented with this library? I think this API would really benefit a lot of RN apps.
(if not I will probably create a separate issue for it)

from clipboard.

EricWiener avatar EricWiener commented on May 28, 2024

Pre-iOS 14, the way to check clipboard content was to look at the data in it, so this is why you get the notification you pasted from the clipboard. The API for iOS 14 has been updated to allow you to check clipboard content without actually looking at the data (and avoiding the notification).

@EricWiener is this implemented with this library? I think this API would really benefit a lot of RN apps.
(if not I will probably create a separate issue for it)

@filiptronicek It hasn't been implemented here yet (I just took a look at the commits). I'd be happy to work on it, but I won't be able to start until August 21st (restricted by current job).

from clipboard.

samzmann avatar samzmann commented on May 28, 2024

@focux Do you have an example of something that works?

I build a custom hook using the Clipboard methods instead of useClipboard, but still see the toast message in some cases.

export const useCustomClipboard = () => {
  const [clipboardContent, setClipboardContent] = useState('')

  // This effect gets the native Clipboard content on first mount
  // and sets clipboardContent accordingly
  useEffect(() => {
    Clipboard.getString().then(setClipboardContent)
  }, [])

  // This effect sets native Clipboard string when clipboardContent changes
  useEffect(() => {
    Clipboard.setString(clipboardContent)
  }, [clipboardContent])


  return [clipboardContent, setClipboardContent]
}

Weirdly, I consistently get the toast message every time I call Clipboard.getString() with a new string in the clipboard...

from clipboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.