diff --git a/components/affix/demo/basic.md b/components/affix/demo/basic.md index a33d0d5f8a..7620445b41 100644 --- a/components/affix/demo/basic.md +++ b/components/affix/demo/basic.md @@ -17,7 +17,7 @@ The simplest usage. import React, { useState } from 'react'; import { Affix, Button } from 'antd'; -const Demo: React.FC = () => { +const App: React.FC = () => { const [top, setTop] = useState(10); const [bottom, setBottom] = useState(10); @@ -38,5 +38,5 @@ const Demo: React.FC = () => { ); }; -export default Demo; +export default App; ``` diff --git a/components/affix/demo/debug.md b/components/affix/demo/debug.md index 886d8b525a..1947819a9c 100644 --- a/components/affix/demo/debug.md +++ b/components/affix/demo/debug.md @@ -18,8 +18,9 @@ DEBUG import React, { useState } from 'react'; import { Affix, Button } from 'antd'; -const Demo: React.FC = () => { +const App: React.FC = () => { const [top, setTop] = useState(10); + return (
Top
@@ -35,5 +36,5 @@ const Demo: React.FC = () => { ); }; -export default Demo; +export default App; ``` diff --git a/components/affix/demo/on-change.md b/components/affix/demo/on-change.md index 48cdbba705..0395b455d2 100644 --- a/components/affix/demo/on-change.md +++ b/components/affix/demo/on-change.md @@ -14,11 +14,14 @@ title: Callback with affixed state. ```tsx +import React from 'react'; import { Affix, Button } from 'antd'; -export default () => ( +const App: React.FC = () => ( console.log(affixed)}> ); + +export default App; ``` diff --git a/components/affix/demo/target.md b/components/affix/demo/target.md index ba33e30e22..127c08c334 100644 --- a/components/affix/demo/target.md +++ b/components/affix/demo/target.md @@ -17,8 +17,9 @@ Set a `target` for 'Affix', which is listen to scroll event of target element (d import React, { useState } from 'react'; import { Affix, Button } from 'antd'; -const Demo: React.FC = () => { +const App: React.FC = () => { const [container, setContainer] = useState(null); + return (
@@ -30,7 +31,7 @@ const Demo: React.FC = () => { ); }; -export default Demo; +export default App; ``` diff --git a/components/table/demo/sticky.md b/components/table/demo/sticky.md index 16bb4ce505..59acec7087 100644 --- a/components/table/demo/sticky.md +++ b/components/table/demo/sticky.md @@ -13,10 +13,19 @@ title: For long table,need to scroll to view the header and scroll bar,then you can now set the fixed header and scroll bar to follow the page. -```jsx +```tsx +import React, { useState } from 'react'; import { Table, Switch } from 'antd'; +import type { ColumnsType } from 'antd/lib/table'; -const columns = [ +interface DataType { + key: React.Key; + name: string; + age: number; + address: string; +} + +const columns: ColumnsType = [ { title: 'Full Name', width: 100, @@ -83,7 +92,7 @@ const columns = [ }, ]; -const data = []; +const data: DataType[] = []; for (let i = 0; i < 100; i++) { data.push({ key: i, @@ -93,15 +102,15 @@ for (let i = 0; i < 100; i++) { }); } -const Demo = () => { - const [fixedTop, setFixedTop] = React.useState(false); +const App: React.FC = () => { + const [fixedTop, setFixedTop] = useState(false); return ( ( + summary={() => ( @@ -126,5 +135,5 @@ const Demo = () => { ); }; -export default Demo; +export default App; ``` diff --git a/components/table/demo/summary.md b/components/table/demo/summary.md index de47e6f9d0..9a8f00e6fa 100644 --- a/components/table/demo/summary.md +++ b/components/table/demo/summary.md @@ -13,12 +13,27 @@ title: Set summary content by `summary` prop. Sync column fixed status with `Table.Summary.Cell`. You can fixed it by set `Table.Summary` `fixed` prop(since `4.16.0`). -```jsx +```tsx +import React from 'react'; import { Table, Typography } from 'antd'; +import type { ColumnsType } from 'antd/lib/table'; const { Text } = Typography; -const columns = [ +interface DataType { + key: string; + name: string; + borrow: number; + repayment: number; +} + +interface FixedDataType { + key: React.Key; + name: string; + description: string; +} + +const columns: ColumnsType = [ { title: 'Name', dataIndex: 'name', @@ -33,7 +48,7 @@ const columns = [ }, ]; -const data = [ +const data: DataType[] = [ { key: '1', name: 'John Brown', @@ -60,7 +75,7 @@ const data = [ }, ]; -const fixedColumns = [ +const fixedColumns: ColumnsType = [ { title: 'Name', dataIndex: 'name', @@ -73,7 +88,7 @@ const fixedColumns = [ }, ]; -const fixedData = []; +const fixedData: FixedDataType[] = []; for (let i = 0; i < 20; i += 1) { fixedData.push({ key: i, @@ -82,7 +97,7 @@ for (let i = 0; i < 20; i += 1) { }); } -export default () => ( +const App: React.FC = () => ( <>
( return ( <> - Total - + Total + {totalBorrow} - + {totalRepayment} - Balance - + Balance + {totalBorrow - totalRepayment} @@ -139,6 +154,8 @@ export default () => ( /> ); + +export default App; ```