mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
Fix Next problem with copy
Next complains when the server renders something different then the client, therfor we move the differing logic to `useEffect`
This commit is contained in:
parent
4c7552dcb1
commit
c3e1c771ac
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useRef } from 'react'
|
import React, { useState, useRef, useEffect } from 'react'
|
||||||
|
|
||||||
import Icon from './icon'
|
import Icon from './icon'
|
||||||
import classes from '../styles/copy.module.sass'
|
import classes from '../styles/copy.module.sass'
|
||||||
|
@ -16,7 +16,11 @@ export function copyToClipboard(ref, callback) {
|
||||||
|
|
||||||
export default function CopyInput({ text, prefix }) {
|
export default function CopyInput({ text, prefix }) {
|
||||||
const isClient = typeof window !== 'undefined'
|
const isClient = typeof window !== 'undefined'
|
||||||
const supportsCopy = isClient && document.queryCommandSupported('copy')
|
const [supportsCopy, setSupportsCopy] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSupportsCopy(isClient && document.queryCommandSupported('copy'))
|
||||||
|
}, [])
|
||||||
const textareaRef = useRef()
|
const textareaRef = useRef()
|
||||||
const [copySuccess, setCopySuccess] = useState(false)
|
const [copySuccess, setCopySuccess] = useState(false)
|
||||||
const onClick = () => copyToClipboard(textareaRef, setCopySuccess)
|
const onClick = () => copyToClipboard(textareaRef, setCopySuccess)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user