-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(list-picker): 优化list-picker、cascader性能 (#1579)
- Loading branch information
1 parent
22992ba
commit 3c893f8
Showing
18 changed files
with
302 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,21 @@ | ||
import React from 'react'; | ||
import React, { useContext } from 'react'; | ||
import { ItemProps } from './interfance'; | ||
import BaseItem from './inner/baseItem'; | ||
import CheckboxItem from './inner/CheckboxItem'; | ||
import CalcaderItem from './inner/CascaderItem'; | ||
import WithRef from '../utils/withRef'; | ||
import { ListContext } from './context'; | ||
|
||
export const Item = WithRef<HTMLLIElement, ItemProps & { isMultiple?: boolean; isCascader?: boolean }>( | ||
(props, ref?) => { | ||
const { label, value, disabled, isMultiple = false, isCascader, selectValue, ...rest } = props; | ||
|
||
if (isMultiple) { | ||
return <CheckboxItem ref={ref} label={label} value={value} disabled={disabled} {...rest} />; | ||
} | ||
if (isCascader) { | ||
return ( | ||
<CalcaderItem | ||
ref={ref} | ||
label={label as string} | ||
value={value as string} | ||
selectValue={selectValue as string} | ||
disabled={disabled} | ||
{...rest} | ||
/> | ||
); | ||
} | ||
return <BaseItem ref={ref} label={label} value={value} disabled={disabled} {...rest} />; | ||
export const Item = WithRef<HTMLLIElement, ItemProps>((props, ref?) => { | ||
const { label, value, disabled, ...rest } = props; | ||
const { model } = useContext(ListContext); | ||
if (model === 'multiple') { | ||
return <CheckboxItem ref={ref} label={label} value={value} disabled={disabled} {...rest} />; | ||
} | ||
if (model === 'cascader') { | ||
return <CalcaderItem ref={ref} label={label as string} value={value as string} disabled={disabled} {...rest} />; | ||
} | ||
); | ||
return <BaseItem ref={ref} label={label} value={value} disabled={disabled} {...rest} />; | ||
}); | ||
|
||
export default Item; |
Oops, something went wrong.
3c893f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: