ant-design/components/list/demo/grid-test.md
偏右 31a9fffeac
fix: List grid not working in React.Fragment or wrapped List.Item (#24955)
* fix: List grid not working for Fragment or wrapping List.Item

close #24553
close #24828

* remove unused code

* no need extra wrap div for List without grid prop
2020-06-12 18:11:29 +08:00

1.1 KiB

order title debug
4.1
zh-CN en-US
测试栅格列表 Test Grid
true

zh-CN

List grid 在各种情况下的样式表现,如 Fragment 和封装了 List.Item.

en-US

Test List grid for some edge cases.

import { List, Card } from 'antd';

const data = [
  {
    title: 'Title 1',
  },
  {
    title: 'Title 2',
  },
  {
    title: 'Title 3',
  },
  {
    title: 'Title 4',
  },
  {
    title: 'Title 5',
  },
    {
    title: 'Title 6',
  },
];

const ListItem = () => (
  <List.Item>
    <Card title="title">Card content</Card>
  </List.Item>
);

ReactDOM.render(
  <>
    <List
      grid={{ gutter: 16, column: 4 }}
      dataSource={data}
      renderItem={item => (
        <>
          <List.Item>
            <Card title={item.title}>Card content</Card>
          </List.Item>
        </>
      )}
    />
    <List
      grid={{ gutter: 16, column: 4 }}
      dataSource={data}
      renderItem={() => <ListItem />}
    />
    <List
      grid={{ gutter: 16, column: 4 }}
      dataSource={data}
      renderItem={() => (
        <>
          <ListItem />
          <div />
        </>
      )}
    />
  </>,
  mountNode,
);