Browse Source

Fix a Transfer perfermance issue of repeat render (#2112)

pull/2297/head
afc163 9 years ago
parent
commit
08311314ee
  1. 18
      components/transfer/list.jsx

18
components/transfer/list.jsx

@ -128,17 +128,7 @@ export default class TransferList extends React.Component {
[`${prefixCls}-with-footer`]: !!footerDom,
});
const showItems = dataSource.filter((item) => {
const renderResult = render(item);
let itemText;
if (isRenderResultPlainObject(renderResult)) {
itemText = renderResult.value;
} else {
itemText = renderResult;
}
const filterResult = this.matchFilter(itemText, filter);
return !!filterResult;
}).map((item) => {
const showItems = dataSource.map((item) => {
const renderResult = render(item);
let renderedText;
let renderedEl;
@ -151,13 +141,17 @@ export default class TransferList extends React.Component {
renderedEl = renderResult;
}
if (filter && filter.trim() && !this.matchFilter(renderedText, filter)) {
return null;
}
return (
<li onClick={() => { this.handleSelect(item); }} key={item.key} title={renderedText}>
<Checkbox checked={checkedKeys.some(key => key === item.key)} />
<span>{renderedEl}</span>
</li>
);
});
}).filter(item => !!item);
let unit = '条';
if (this.context.antLocale &&

Loading…
Cancel
Save