Skip to content

Commit

Permalink
[fix] cache Clipboard.isAvailable() value
Browse files Browse the repository at this point in the history
Fix #1149
Close #1150
  • Loading branch information
comp615 authored and necolas committed Oct 23, 2018
1 parent 5033e12 commit 5855e55
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/react-native-web/src/exports/Clipboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
* @flow
*/

let clipboardAvailable;

export default class Clipboard {
static isAvailable() {
return (
typeof document.queryCommandSupported === 'function' && document.queryCommandSupported('copy')
);
if (clipboardAvailable === undefined) {
clipboardAvailable =
typeof document.queryCommandSupported === 'function' &&
document.queryCommandSupported('copy');
}
return clipboardAvailable;
}

static getString(): Promise<string> {
Expand Down

0 comments on commit 5855e55

Please sign in to comment.