Skip to content

Commit 5dc0b60

Browse files
authored
Merge branch 'master' into master
2 parents 45887f4 + 5f9bd61 commit 5dc0b60

File tree

8 files changed

+597
-586
lines changed

8 files changed

+597
-586
lines changed

.all-contributorsrc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"avatar_url": "https://avatars0.githubusercontent.com/u/189580?v=4",
7373
"profile": "http://linus.unnebäck.se/",
7474
"contributions": [
75-
"code"
75+
"code",
76+
"infra"
7677
]
7778
},
7879
{
@@ -128,7 +129,9 @@
128129
"contributions": [
129130
"infra",
130131
"platform",
131-
"tool"
132+
"tool",
133+
"code",
134+
"doc"
132135
]
133136
},
134137
{
@@ -166,6 +169,24 @@
166169
"contributions": [
167170
"code"
168171
]
172+
},
173+
{
174+
"login": "thinklinux",
175+
"name": "Tihomir Valkanov",
176+
"avatar_url": "https://avatars1.githubusercontent.com/u/326949?v=4",
177+
"profile": "https://github.com/thinklinux",
178+
"contributions": [
179+
"doc"
180+
]
181+
},
182+
{
183+
"login": "pistou",
184+
"name": "Pierre Skowron",
185+
"avatar_url": "https://avatars1.githubusercontent.com/u/6703711?v=4",
186+
"profile": "http://twitter.com/pistoudev",
187+
"contributions": [
188+
"code"
189+
]
169190
}
170191
],
171192
"contributorsPerLine": 7

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ jobs:
2525
- run:
2626
name: Jest
2727
command: yarn test
28+
release-canary:
29+
executor: rn/linux_js
30+
steps:
31+
- attach_workspace:
32+
at: .
33+
- rn/yarn_install
34+
- run:
35+
name: Publish a canary release to NPM
36+
command: yarn release-canary
2837
release:
2938
executor: rn/linux_js
3039
steps:
@@ -43,6 +52,15 @@ workflows:
4352
- analyze:
4453
requires:
4554
- checkout_code
55+
- release-canary:
56+
requires:
57+
- analyze
58+
filters:
59+
branches:
60+
ignore: master
4661
- release:
4762
requires:
4863
- analyze
64+
filters:
65+
branches:
66+
only: master

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect -->
2+
3+
# Summary
4+
5+
<!--
6+
Explain the **motivation** for making this change: here are some points to help you:
7+
8+
* What issues does the pull request solve? Please tag them so that they will get automatically closed once the PR is merged
9+
* What is the feature? (if applicable)
10+
* How did you implement the solution?
11+
* What areas of the library does it impact?
12+
-->
13+
14+
## Test Plan
15+
16+
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
17+
18+
### What's required for testing (prerequisites)?
19+
20+
### What are the steps to reproduce (after prerequisites)?
21+
22+
## Compatibility
23+
24+
| OS | Implemented |
25+
| ------- | :---------: |
26+
| iOS | ✅❌ |
27+
| Android | ✅❌ |
28+
| Web | ✅❌ |
29+
30+
## Checklist
31+
32+
<!-- Check completed item, when applicable, via: [X] -->
33+
34+
- [ ] I have tested this on a device and a simulator
35+
- [ ] I added the documentation in `README.md`
36+
- [ ] I updated the typed files (TS and Flow)
37+
- [ ] I've created a snack to demonstrate the changes: LINK HERE

CHANGELOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
# v2.4.6 (Wed Mar 18 2020)
2+
3+
:tada: This release contains work from a new contributor! :tada:
4+
5+
Thank you, WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot)), for all your work!
6+
7+
#### 🐛 Bug Fix
8+
9+
- chore: specify type for clipboard [#82](https://github.com/react-native-community/hooks/pull/82) ([@Naturalclar](https://github.com/Naturalclar))
10+
- Pin dependencies [#80](https://github.com/react-native-community/hooks/pull/80) ([@renovate-bot](https://github.com/renovate-bot) [@renovate[bot]](https://github.com/renovate[bot]))
11+
- upgrade a bunch of versions [#79](https://github.com/react-native-community/hooks/pull/79) ([@pvinis](https://github.com/pvinis))
12+
13+
#### Authors: 4
14+
15+
- [@renovate[bot]](https://github.com/renovate[bot])
16+
- Jesse Katsumata ([@Naturalclar](https://github.com/Naturalclar))
17+
- Pavlos Vinieratos ([@pvinis](https://github.com/pvinis))
18+
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
19+
20+
---
21+
22+
# v2.4.5 (Mon Mar 16 2020)
23+
24+
#### 🐛 Bug Fix
25+
26+
- Use a global list of clipboard listeners [#76](https://github.com/react-native-community/hooks/pull/76) ([@LinusU](https://github.com/LinusU))
27+
28+
#### Authors: 1
29+
30+
- Linus Unnebäck ([@LinusU](https://github.com/LinusU))
31+
32+
---
33+
34+
# v2.4.4 (Mon Mar 16 2020)
35+
36+
:tada: This release contains work from new contributors! :tada:
37+
38+
Thanks for all your work!
39+
40+
:heart: Tihomir Valkanov ([@thinklinux](https://github.com/thinklinux))
41+
42+
:heart: Pierre Skowron ([@pistou](https://github.com/pistou))
43+
44+
#### 🐛 Bug Fix
45+
46+
- Bump acorn from 6.4.0 to 6.4.1 [#78](https://github.com/react-native-community/hooks/pull/78) ([@dependabot[bot]](https://github.com/dependabot[bot]))
47+
- Create PULL_REQUEST_TEMPLATE.md [#77](https://github.com/react-native-community/hooks/pull/77) ([@LinusU](https://github.com/LinusU))
48+
- Correcting documentation for useKeyboard hook [#75](https://github.com/react-native-community/hooks/pull/75) ([@thinklinux](https://github.com/thinklinux))
49+
- Improve unsubscription [#48](https://github.com/react-native-community/hooks/pull/48) ([@pistou](https://github.com/pistou) [@pvinis](https://github.com/pvinis))
50+
- Update auto + add initial contributor table [#73](https://github.com/react-native-community/hooks/pull/73) ([@hipstersmoothie](https://github.com/hipstersmoothie) [@pvinis](https://github.com/pvinis))
51+
- put in file [#74](https://github.com/react-native-community/hooks/pull/74) ([@pvinis](https://github.com/pvinis))
52+
53+
#### ⚠️ Pushed to master
54+
55+
- lint ([@pvinis](https://github.com/pvinis))
56+
- Update README.md ([@pvinis](https://github.com/pvinis))
57+
58+
#### Authors: 6
59+
60+
- [@dependabot[bot]](https://github.com/dependabot[bot])
61+
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
62+
- Linus Unnebäck ([@LinusU](https://github.com/LinusU))
63+
- Pavlos Vinieratos ([@pvinis](https://github.com/pvinis))
64+
- Pierre Skowron ([@pistou](https://github.com/pistou))
65+
- Tihomir Valkanov ([@thinklinux](https://github.com/thinklinux))
66+
67+
---
68+
169
# v2.4.3 (Sat Feb 22 2020)
270

371
#### 🐛 Bug Fix

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ yarn add @react-native-community/hooks
3737
```js
3838
import { useAccessibilityInfo } from '@react-native-community/hooks'
3939

40-
const isScreenReaderEnabled = useAccessibilityInfo()
40+
const { reduceMotionEnabled, screenReaderEnabled } = useAccessibilityInfo()
4141
```
4242

4343
### `useAppState`
@@ -164,8 +164,9 @@ console.log('layout: ', layout)
164164
[version-badge]: https://img.shields.io/npm/v/@react-native-community/hooks.svg?style=flat-square
165165
[package]: https://www.npmjs.com/package/@react-native-community/hooks
166166

167-
We use [auto](https://github.com/intuit/auto) for automatic releases, an awesome tool by an awesome [dude](https://github.com/hipstersmoothie)!
167+
## Thanks
168168

169+
We use [auto](https://github.com/intuit/auto) for automatic releases, an awesome tool by an awesome [dude](https://github.com/hipstersmoothie)!
169170

170171
## Contributors ✨
171172

@@ -181,21 +182,23 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
181182
<td align="center"><a href="https://naturalclar.dev"><img src="https://avatars1.githubusercontent.com/u/6936373?v=4" width="100px;" alt=""/><br /><sub><b>Jesse Katsumata</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=Naturalclar" title="Code">💻</a> <a href="https://github.com/react-native-community/hooks/commits?author=Naturalclar" title="Documentation">📖</a> <a href="#maintenance-Naturalclar" title="Maintenance">🚧</a> <a href="https://github.com/react-native-community/hooks/commits?author=Naturalclar" title="Tests">⚠️</a></td>
182183
<td align="center"><a href="https://twitter.com/webtaculars"><img src="https://avatars0.githubusercontent.com/u/11532969?v=4" width="100px;" alt=""/><br /><sub><b>abhishek gupta</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/issues?q=author%3Awebtaculars" title="Bug reports">🐛</a></td>
183184
<td align="center"><a href="http://www.linkedin.com/in/zeljko-markovic-19266344"><img src="https://avatars3.githubusercontent.com/u/2046481?v=4" width="100px;" alt=""/><br /><sub><b>Zeljko</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=zeljkoX" title="Code">💻</a></td>
184-
<td align="center"><a href="http://linus.unnebäck.se/"><img src="https://avatars0.githubusercontent.com/u/189580?v=4" width="100px;" alt=""/><br /><sub><b>Linus Unnebäck</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=LinusU" title="Code">💻</a></td>
185+
<td align="center"><a href="http://linus.unnebäck.se/"><img src="https://avatars0.githubusercontent.com/u/189580?v=4" width="100px;" alt=""/><br /><sub><b>Linus Unnebäck</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=LinusU" title="Code">💻</a> <a href="#infra-LinusU" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
185186
<td align="center"><a href="http://stackoverflow.com/users/692499/tony"><img src="https://avatars1.githubusercontent.com/u/696842?v=4" width="100px;" alt=""/><br /><sub><b>Tony Xiao</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=tonyxiao" title="Code">💻</a></td>
186187
</tr>
187188
<tr>
188189
<td align="center"><a href="https://github.com/ronal2do"><img src="https://avatars3.githubusercontent.com/u/4389565?v=4" width="100px;" alt=""/><br /><sub><b>Ronaldo Lima</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=ronal2do" title="Code">💻</a></td>
189190
<td align="center"><a href="https://mariusreimer.com"><img src="https://avatars3.githubusercontent.com/u/15148377?v=4" width="100px;" alt=""/><br /><sub><b>Marius Reimer</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=reime005" title="Code">💻</a></td>
190191
<td align="center"><a href="https://github.com/pnishith"><img src="https://avatars1.githubusercontent.com/u/24517032?v=4" width="100px;" alt=""/><br /><sub><b>Nishith Patel</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=pnishith" title="Code">💻</a></td>
191192
<td align="center"><a href="https://github.com/jozn"><img src="https://avatars2.githubusercontent.com/u/3476299?v=4" width="100px;" alt=""/><br /><sub><b>jozn</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=jozn" title="Documentation">📖</a></td>
192-
<td align="center"><a href="http://hipstersmoothie.com"><img src="https://avatars3.githubusercontent.com/u/1192452?v=4" width="100px;" alt=""/><br /><sub><b>Andrew Lisowski</b></sub></a><br /><a href="#infra-hipstersmoothie" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-hipstersmoothie" title="Packaging/porting to new platform">📦</a> <a href="#tool-hipstersmoothie" title="Tools">🔧</a></td>
193+
<td align="center"><a href="http://hipstersmoothie.com"><img src="https://avatars3.githubusercontent.com/u/1192452?v=4" width="100px;" alt=""/><br /><sub><b>Andrew Lisowski</b></sub></a><br /><a href="#infra-hipstersmoothie" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-hipstersmoothie" title="Packaging/porting to new platform">📦</a> <a href="#tool-hipstersmoothie" title="Tools">🔧</a> <a href="https://github.com/react-native-community/hooks/commits?author=hipstersmoothie" title="Code">💻</a> <a href="https://github.com/react-native-community/hooks/commits?author=hipstersmoothie" title="Documentation">📖</a></td>
193194
<td align="center"><a href="https://linkedin.com/in/farazamiruddin"><img src="https://avatars2.githubusercontent.com/u/6789822?v=4" width="100px;" alt=""/><br /><sub><b>faraz ahmad</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=faahmad" title="Documentation">📖</a></td>
194195
<td align="center"><a href="http://www.naderdabit.me"><img src="https://avatars1.githubusercontent.com/u/1857282?v=4" width="100px;" alt=""/><br /><sub><b>Nader Dabit</b></sub></a><br /><a href="#ideas-dabit3" title="Ideas, Planning, & Feedback">🤔</a></td>
195196
</tr>
196197
<tr>
197198
<td align="center"><a href="http://twitter.com/dani_akash_"><img src="https://avatars3.githubusercontent.com/u/6841445?v=4" width="100px;" alt=""/><br /><sub><b>Dani Akash</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=DaniAkash" title="Code">💻</a></td>
198199
<td align="center"><a href="https://dylanvann.com/"><img src="https://avatars0.githubusercontent.com/u/1537615?v=4" width="100px;" alt=""/><br /><sub><b>Dylan Vann</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=DylanVann" title="Code">💻</a></td>
200+
<td align="center"><a href="https://github.com/thinklinux"><img src="https://avatars1.githubusercontent.com/u/326949?v=4" width="100px;" alt=""/><br /><sub><b>Tihomir Valkanov</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=thinklinux" title="Documentation">📖</a></td>
201+
<td align="center"><a href="http://twitter.com/pistoudev"><img src="https://avatars1.githubusercontent.com/u/6703711?v=4" width="100px;" alt=""/><br /><sub><b>Pierre Skowron</b></sub></a><br /><a href="https://github.com/react-native-community/hooks/commits?author=pistou" title="Code">💻</a></td>
199202
</tr>
200203
</table>
201204

package.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-community/hooks",
3-
"version": "2.4.3",
3+
"version": "2.4.6",
44
"description": "",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -9,32 +9,33 @@
99
"build": "tsc",
1010
"test": "jest",
1111
"lint": "eslint src/**/*.ts",
12-
"release": "auto shipit"
12+
"release": "auto shipit",
13+
"release-canary": "auto canary"
1314
},
1415
"peerDependencies": {
1516
"react": ">=16.8.0",
1617
"react-native": ">=0.59"
1718
},
1819
"devDependencies": {
19-
"@auto-it/all-contributors": "^9.12.0",
20-
"@auto-it/first-time-contributor": "^9.12.0",
21-
"@react-native-community/eslint-config": "^0.0.7",
22-
"@testing-library/react-hooks": "^3.2.1",
23-
"@testing-library/react-native": "^5.0.3",
24-
"@types/jest": "^25.1.3",
25-
"@types/react": "^16.9.10",
26-
"@types/react-native": "^0.61.0",
27-
"all-contributors-cli": "^6.13.0",
28-
"auto": "^9.12.0",
29-
"eslint": "^6.8.0",
30-
"eslint-plugin-prettier": "^3.1.2",
31-
"jest": "^25.1.0",
32-
"prettier": "^1.19.1",
33-
"react": "^16.12.0",
34-
"react-native": "^0.61.5",
35-
"react-test-renderer": "^16.12.0",
36-
"ts-jest": "^25.2.1",
37-
"typescript": "^3.6.4"
20+
"@auto-it/all-contributors": "9.20.0",
21+
"@auto-it/first-time-contributor": "9.20.0",
22+
"@react-native-community/eslint-config": "0.0.7",
23+
"@testing-library/react-hooks": "3.2.1",
24+
"@testing-library/react-native": "5.0.3",
25+
"@types/jest": "25.1.4",
26+
"@types/react": "16.9.23",
27+
"@types/react-native": "0.61.23",
28+
"all-contributors-cli": "6.14.0",
29+
"auto": "9.20.0",
30+
"eslint": "6.8.0",
31+
"eslint-plugin-prettier": "3.1.2",
32+
"jest": "25.1.0",
33+
"prettier": "1.19.1",
34+
"react": "16.13.0",
35+
"react-native": "0.61.5",
36+
"react-test-renderer": "16.13.0",
37+
"ts-jest": "25.2.1",
38+
"typescript": "3.8.3"
3839
},
3940
"author": "Nader Dabit",
4041
"repository": {

src/useClipboard.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
import {useEffect, useState} from 'react'
22
import {Clipboard} from 'react-native'
33

4-
export default function useClipBoard() {
5-
const [data, updateClipboardData] = useState('')
4+
type Listener = (content: string) => void
5+
const listeners = new Set<Listener>()
6+
7+
function setString(content: string) {
8+
Clipboard.setString(content)
9+
listeners.forEach(listener => listener(content))
10+
}
611

7-
async function updateClipboard() {
8-
const content = await Clipboard.getString()
9-
updateClipboardData(content)
10-
}
12+
export default function useClipBoard(): [string, (content: string) => void] {
13+
const [data, updateClipboardData] = useState('')
1114

15+
// Get initial data
1216
useEffect(() => {
13-
updateClipboard()
17+
Clipboard.getString().then(updateClipboardData)
1418
}, [])
1519

16-
function setString(content: string) {
17-
Clipboard.setString(content)
18-
updateClipboardData(content)
19-
}
20+
// Listen for updates
21+
useEffect(() => {
22+
listeners.add(updateClipboardData)
23+
24+
return () => {
25+
listeners.delete(updateClipboardData)
26+
}
27+
}, [])
2028

2129
return [data, setString]
2230
}

0 commit comments

Comments
 (0)