Skip to content

Commit e901875

Browse files
authored
fix: flash of it (#551)
1 parent b6f6d87 commit e901875

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/Picker.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@
1111
* Tips: Should add faq about `datetime` mode with `defaultValue`
1212
*/
1313

14-
import * as React from 'react';
1514
import classNames from 'classnames';
1615
import type { AlignType } from 'rc-trigger/lib/interface';
17-
import warning from 'rc-util/lib/warning';
1816
import useMergedState from 'rc-util/lib/hooks/useMergedState';
17+
import warning from 'rc-util/lib/warning';
18+
import * as React from 'react';
19+
import useHoverValue from './hooks/useHoverValue';
20+
import usePickerInput from './hooks/usePickerInput';
21+
import usePresets from './hooks/usePresets';
22+
import useTextValueMapping from './hooks/useTextValueMapping';
23+
import useValueTexts from './hooks/useValueTexts';
24+
import type { CustomFormat, PickerMode, PresetDate } from './interface';
25+
import type { ContextOperationRefProps } from './PanelContext';
26+
import PanelContext from './PanelContext';
1927
import type {
2028
PickerPanelBaseProps,
2129
PickerPanelDateProps,
2230
PickerPanelTimeProps,
2331
} from './PickerPanel';
2432
import PickerPanel from './PickerPanel';
2533
import PickerTrigger from './PickerTrigger';
34+
import PresetPanel from './PresetPanel';
2635
import { formatValue, isEqual, parseValue } from './utils/dateUtil';
2736
import getDataOrAriaProps, { toArray } from './utils/miscUtil';
28-
import type { ContextOperationRefProps } from './PanelContext';
29-
import PanelContext from './PanelContext';
30-
import type { CustomFormat, PickerMode, PresetDate } from './interface';
31-
import { getDefaultFormat, getInputSize, elementsContains } from './utils/uiUtil';
32-
import usePickerInput from './hooks/usePickerInput';
33-
import useTextValueMapping from './hooks/useTextValueMapping';
34-
import useValueTexts from './hooks/useValueTexts';
35-
import useHoverValue from './hooks/useHoverValue';
37+
import { elementsContains, getDefaultFormat, getInputSize } from './utils/uiUtil';
3638
import { legacyPropsWarning } from './utils/warnUtil';
37-
import usePresets from './hooks/usePresets';
38-
import PresetPanel from './PresetPanel';
3939

4040
export type PickerRefConfig = {
4141
focus: () => void;
@@ -271,7 +271,6 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
271271
return;
272272
}
273273

274-
console.trace('New Open:', newOpen)
275274
triggerInnerOpen(newOpen);
276275
};
277276

src/hooks/useTextValueMapping.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
12
import * as React from 'react';
23

34
export default function useTextValueMapping({
@@ -21,8 +22,8 @@ export default function useTextValueMapping({
2122
setInnerText(valueTextsRef.current[0]);
2223
}
2324

24-
React.useEffect(() => {
25-
if (valueTexts.every(valText => valText !== text)) {
25+
useLayoutEffect(() => {
26+
if (valueTexts.every((valText) => valText !== text)) {
2627
resetText();
2728
}
2829
}, [valueTexts.join('||')]);

0 commit comments

Comments
 (0)