Skip to content

Commit a984134

Browse files
authored
fix: only access window object after app is loaded (#170)
1 parent 35b9c81 commit a984134

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/color-chrome/src/EyeDropper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22

3-
export const isSupportEyeDropper = 'EyeDropper' in window;
3+
export function getIsEyeDropperSupported() {
4+
return 'EyeDropper' in window;
5+
}
46

57
export interface EyeDropperProps {
68
onPickColor?: (color: string) => void;

packages/color-chrome/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import EditableInputRGBA from '@uiw/react-color-editable-input-rgba';
1717
import EditableInputHSLA from '@uiw/react-color-editable-input-hsla';
1818
import { useState } from 'react';
1919
import Arrow from './Arrow';
20-
import { EyeDropper, isSupportEyeDropper } from './EyeDropper';
20+
import { EyeDropper, getIsEyeDropperSupported } from './EyeDropper';
2121

2222
export enum ChromeInputType {
2323
HEXA = 'hexa',
@@ -111,7 +111,7 @@ const Chrome = React.forwardRef<HTMLDivElement, ChromeProps>((props, ref) => {
111111
}}
112112
/>
113113
<div style={{ padding: 15, display: 'flex', alignItems: 'center', gap: 10 }}>
114-
{isSupportEyeDropper && showEyeDropper && <EyeDropper onPickColor={handleClickColor} />}
114+
{getIsEyeDropperSupported() && showEyeDropper && <EyeDropper onPickColor={handleClickColor} />}
115115
{showColorPreview && (
116116
<Alpha
117117
width={28}

0 commit comments

Comments
 (0)