mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
Type errors only in development
This commit is contained in:
parent
90d0a5ddb6
commit
8b04ef0d6d
@ -19,17 +19,15 @@ const useCopyToClipboard = (): [CopyToClipboardState, (value: string) => void] =
|
||||
|
||||
const copyToClipboard = useCallback((value) => {
|
||||
try {
|
||||
if (!value) {
|
||||
throw new Error('No value to copy to clipboard')
|
||||
}
|
||||
|
||||
if (typeof value !== "string") {
|
||||
throw new Error(`Cannot copy typeof ${typeof value} to clipboard, must be a string`);
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (typeof value !== "string") {
|
||||
console.error(`Cannot copy typeof ${typeof value} to clipboard, must be a string`);
|
||||
}
|
||||
}
|
||||
|
||||
const noUserInteraction = writeText(value);
|
||||
if (!mounted.current) return;
|
||||
|
||||
if (!mounted.current) return;
|
||||
setState({
|
||||
value,
|
||||
error: undefined,
|
||||
@ -37,7 +35,6 @@ const useCopyToClipboard = (): [CopyToClipboardState, (value: string) => void] =
|
||||
});
|
||||
} catch (error) {
|
||||
if (!mounted.current) return;
|
||||
|
||||
setState({
|
||||
value: undefined,
|
||||
error,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user