Skip to content

Commit

Permalink
fix(list-picker): fix list-picker multiple error (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
berber1016 committed Dec 1, 2021
1 parent 1ef2bb9 commit 4597f09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/list-picker/listPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import classNames from 'classnames';
import { isEqual, isNil } from 'lodash';
import { ListPickerProps } from './interfance';
Expand Down Expand Up @@ -51,10 +51,11 @@ const ListPicker: React.FC<ListPickerProps> = (props) => {
const defaultPrefix = usePrefixCls(prefixCls);
const [visible, setVisible] = useControlledState(controlledVisible, false);

const [value, setValue] = useControlledState(controlledValue, defaultValue);
const [value, setValue] = useState(controlledValue || defaultValue);
const { options, setOptions, getOptionByValue, getLabelByValue, getOptionsByValue } = useCacheOptions();

useEffect(() => {
console.log('执行');
setValue(controlledValue);
}, [controlledValue, setValue]);
useEffect(() => {
Expand Down Expand Up @@ -83,6 +84,7 @@ const ListPicker: React.FC<ListPickerProps> = (props) => {
onChange?.(val, opts);
handVisibleChange(false);
} else {
console.log('val', val);
setValue(val);
}
};
Expand Down
1 change: 0 additions & 1 deletion src/select/demos/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export const Default = () => {
return (
<Select
options={options}
value="1"
contentStyle={{ width: '300px' }}
placeholder="请选择"
size="normal"
Expand Down

1 comment on commit 4597f09

@vercel
Copy link

@vercel vercel bot commented on 4597f09 Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.