Use a global list of clipboard listeners#76
Conversation
|
@pvinis hmm, is the checklist up to date? I went to add my changes to the changelog but it seems like it's generated automatically? |
|
Indeed. we need to revisit that. |
|
Ahh, it comes from here: https://github.com/react-native-community/.github/blob/master/.github/PULL_REQUEST_TEMPLATE.md Hmm, maybe we can just override it by adding our own version 🤔 |
|
I've added a snack to test this out here: 🎉 |
|
for sure. today and tomorrow I'm not easily next to my laptop, I could check later, or if you do something we check it. |
|
Did it here: #77 This PR should be ready for review now, I've tested it on my iPhone and on the Web. Should be super easy for anyone to test out the snack |
|
having the snack is awesome! maybe we can add this in the template as a suggestion? 🤔 |
|
I also plan to add some tests so people can copy paste and use them too. |
Hehe, already did it in #77 😉
Maybe we could have an official snack which uses all the hooks. Then people can just fork that one and add whatever is specific to their PR? 🤔 Since each PR gets deployed with a canary version it's super easy to use them in the snacks 🙌 |
|
yuuuuuuuuuusssssss!!! awesome idea. |
|
ping @pvinis, can we merge this? |
|
uup, forgot that. No one reviewed, lemme give it a look. |
|
For reference, here is the broken version https://snack.expo.io/ByOfrk6r8 |
|
🚀 PR was released in |

Summary
Before this change, if two components on the same page used the clipboard hook, one of them wouldn't properly re-render if the other one updated the clipboard content.
Test Plan
I'm working on a small example app that shows two components that uses the clipboard at the same time, and demonstrates that it now works.Here is a snack that demonstrates the working behaviour:
https://snack.expo.io/@linusu/hooks-pr-76
What's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.mdCHANGELOG.mdexample/App.js)📦 Published PR as canary version:
2.4.4-canary.76.172.0✨ Test out this PR locally via:
npm install @react-native-community/hooks@2.4.4-canary.76.172.0 # or yarn add @react-native-community/hooks@2.4.4-canary.76.172.0