Skip to content

Commit d3bdf8e

Browse files
committed
Merge branch 'master' of https://github.com/Greg-Bush/hooks
2 parents 2424139 + c693037 commit d3bdf8e

File tree

8 files changed

+625
-586
lines changed

8 files changed

+625
-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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,99 @@
1+
# v2.4.7 (Thu Mar 19 2020)
2+
3+
:tada: This release contains work from new contributors! :tada:
4+
5+
Thanks for all your work!
6+
7+
:heart: WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
8+
9+
:heart: Peter Makowski ([@petermakowski](https://github.com/petermakowski))
10+
11+
#### 🐛 Bug Fix
12+
13+
- test [#89](https://github.com/react-native-community/hooks/pull/89) ([@pvinis](https://github.com/pvinis))
14+
- Update dependency auto to v9.20.0 [#88](https://github.com/react-native-community/hooks/pull/88) ([@renovate-bot](https://github.com/renovate-bot) [@renovate[bot]](https://github.com/renovate[bot]))
15+
- Update README.md [#84](https://github.com/react-native-community/hooks/pull/84) ([@petermakowski](https://github.com/petermakowski))
16+
- Update dependency @auto-it/all-contributors to v9.20.0 [#85](https://github.com/react-native-community/hooks/pull/85) ([@renovate-bot](https://github.com/renovate-bot) [@renovate[bot]](https://github.com/renovate[bot]))
17+
- Update dependency @auto-it/first-time-contributor to v9.20.0 [#86](https://github.com/react-native-community/hooks/pull/86) ([@renovate-bot](https://github.com/renovate-bot) [@renovate[bot]](https://github.com/renovate[bot]))
18+
- Update dependency @types/react-native to v0.61.23 [#83](https://github.com/react-native-community/hooks/pull/83) ([@renovate-bot](https://github.com/renovate-bot))
19+
20+
#### Authors: 4
21+
22+
- [@renovate[bot]](https://github.com/renovate[bot])
23+
- Pavlos Vinieratos ([@pvinis](https://github.com/pvinis))
24+
- Peter Makowski ([@petermakowski](https://github.com/petermakowski))
25+
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
26+
27+
---
28+
29+
# v2.4.6 (Wed Mar 18 2020)
30+
31+
:tada: This release contains work from a new contributor! :tada:
32+
33+
Thank you, WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot)), for all your work!
34+
35+
#### 🐛 Bug Fix
36+
37+
- chore: specify type for clipboard [#82](https://github.com/react-native-community/hooks/pull/82) ([@Naturalclar](https://github.com/Naturalclar))
38+
- 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]))
39+
- upgrade a bunch of versions [#79](https://github.com/react-native-community/hooks/pull/79) ([@pvinis](https://github.com/pvinis))
40+
41+
#### Authors: 4
42+
43+
- [@renovate[bot]](https://github.com/renovate[bot])
44+
- Jesse Katsumata ([@Naturalclar](https://github.com/Naturalclar))
45+
- Pavlos Vinieratos ([@pvinis](https://github.com/pvinis))
46+
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
47+
48+
---
49+
50+
# v2.4.5 (Mon Mar 16 2020)
51+
52+
#### 🐛 Bug Fix
53+
54+
- Use a global list of clipboard listeners [#76](https://github.com/react-native-community/hooks/pull/76) ([@LinusU](https://github.com/LinusU))
55+
56+
#### Authors: 1
57+
58+
- Linus Unnebäck ([@LinusU](https://github.com/LinusU))
59+
60+
---
61+
62+
# v2.4.4 (Mon Mar 16 2020)
63+
64+
:tada: This release contains work from new contributors! :tada:
65+
66+
Thanks for all your work!
67+
68+
:heart: Tihomir Valkanov ([@thinklinux](https://github.com/thinklinux))
69+
70+
:heart: Pierre Skowron ([@pistou](https://github.com/pistou))
71+
72+
#### 🐛 Bug Fix
73+
74+
- 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]))
75+
- Create PULL_REQUEST_TEMPLATE.md [#77](https://github.com/react-native-community/hooks/pull/77) ([@LinusU](https://github.com/LinusU))
76+
- Correcting documentation for useKeyboard hook [#75](https://github.com/react-native-community/hooks/pull/75) ([@thinklinux](https://github.com/thinklinux))
77+
- Improve unsubscription [#48](https://github.com/react-native-community/hooks/pull/48) ([@pistou](https://github.com/pistou) [@pvinis](https://github.com/pvinis))
78+
- 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))
79+
- put in file [#74](https://github.com/react-native-community/hooks/pull/74) ([@pvinis](https://github.com/pvinis))
80+
81+
#### ⚠️ Pushed to master
82+
83+
- lint ([@pvinis](https://github.com/pvinis))
84+
- Update README.md ([@pvinis](https://github.com/pvinis))
85+
86+
#### Authors: 6
87+
88+
- [@dependabot[bot]](https://github.com/dependabot[bot])
89+
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
90+
- Linus Unnebäck ([@LinusU](https://github.com/LinusU))
91+
- Pavlos Vinieratos ([@pvinis](https://github.com/pvinis))
92+
- Pierre Skowron ([@pistou](https://github.com/pistou))
93+
- Tihomir Valkanov ([@thinklinux](https://github.com/thinklinux))
94+
95+
---
96+
197
# v2.4.3 (Sat Feb 22 2020)
298

399
#### 🐛 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`
@@ -169,8 +169,9 @@ console.log('layout: ', layout)
169169
[version-badge]: https://img.shields.io/npm/v/@react-native-community/hooks.svg?style=flat-square
170170
[package]: https://www.npmjs.com/package/@react-native-community/hooks
171171

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

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

175176
## Contributors ✨
176177

@@ -186,21 +187,23 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
186187
<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>
187188
<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>
188189
<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>
189-
<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>
190+
<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>
190191
<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>
191192
</tr>
192193
<tr>
193194
<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>
194195
<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>
195196
<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>
196197
<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>
197-
<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>
198+
<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>
198199
<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>
199200
<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>
200201
</tr>
201202
<tr>
202203
<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>
203204
<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>
205+
<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>
206+
<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>
204207
</tr>
205208
</table>
206209

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.7",
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)