Skip to content

Commit 6643667

Browse files
committed
clipboard
1 parent dba06d7 commit 6643667

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/useClipboard.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { useEffect, useState } from 'react'
2+
import { Clipboard } from 'react-native'
3+
4+
export default () => {
5+
const [data, updateClipboardData] = useState('')
6+
7+
useEffect(() => {
8+
(async () => {
9+
const content = await Clipboard.getString()
10+
updateClipboardData(content)
11+
})()
12+
}, [])
13+
14+
function setString(content: string) {
15+
Clipboard.setString(content)
16+
updateClipboardData(content)
17+
}
18+
19+
return [data, setString]
20+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// "incremental": true, /* Enable incremental compilation */
55
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
66
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7-
// "lib": [], /* Specify library files to be included in the compilation. */
7+
"lib": ["es2018"], /* Specify library files to be included in the compilation. */
88
// "allowJs": true, /* Allow javascript files to be compiled. */
99
// "checkJs": true, /* Report errors in .js files. */
1010
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */

0 commit comments

Comments
 (0)