Skip to content

Commit

Permalink
fix(list-picker): jSON.parse.('') error (#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
berber1016 committed Nov 25, 2021
1 parent e186fb0 commit 2d3625f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/list-picker/listPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ListPicker: React.FC<ListPickerProps> = (props) => {
const handleChange = (val?: string | string[], opts?: OptionProps | OptionProps[]) => {
if (model !== 'multiple') {
const localStorageValue = localStorage?.getItem(ITEM_KEY);
const recentKey: string[] = (JSON.parse(isNil(localStorageValue) ? '' : localStorageValue) || []).filter(
const recentKey: string[] = (JSON.parse(isNil(localStorageValue) ? '[]' : localStorageValue) || []).filter(
(v: string) => v !== val
);
localStorage?.setItem(ITEM_KEY, JSON.stringify([val, ...recentKey].slice(0, 20)));
Expand Down

1 comment on commit 2d3625f

@vercel
Copy link

@vercel vercel bot commented on 2d3625f Nov 25, 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.