2020-03-15 20:53:23 +08:00
|
|
|
---
|
|
|
|
order: 10
|
|
|
|
title: useBreakpoint Hook
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
使用 `useBreakpoint` Hook 个性化布局。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2020-05-07 23:22:31 +08:00
|
|
|
Use `useBreakpoint` Hook provide personalized layout.
|
2020-03-15 20:53:23 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
|
|
|
import React from 'react';
|
2020-04-27 16:59:33 +08:00
|
|
|
import { Grid, Tag } from 'antd';
|
2020-03-15 20:53:23 +08:00
|
|
|
|
|
|
|
const { useBreakpoint } = Grid;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2020-03-15 20:53:23 +08:00
|
|
|
const screens = useBreakpoint();
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2020-03-15 20:53:23 +08:00
|
|
|
return (
|
2020-04-27 16:59:33 +08:00
|
|
|
<>
|
|
|
|
Current break point:{' '}
|
|
|
|
{Object.entries(screens)
|
|
|
|
.filter(screen => !!screen[1])
|
|
|
|
.map(screen => (
|
|
|
|
<Tag color="blue" key={screen[0]}>
|
|
|
|
{screen[0]}
|
|
|
|
</Tag>
|
|
|
|
))}
|
|
|
|
</>
|
2020-03-15 20:53:23 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
};
|
2020-03-15 20:53:23 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
export default App;
|
2020-03-15 20:53:23 +08:00
|
|
|
```
|