mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 16:19:15 +08:00
51da7e3dc1
* feat: Anchor component changed to data-driven * test: add test cases for data driven items * fix: type * chore: mark deprecated for anchor children prop * docs: add items description * test: update snapshot * docs: demos changed to data-driven * docs: Keep the old jsx syntax demo for debugging
48 lines
1009 B
TypeScript
48 lines
1009 B
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { Anchor } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [targetOffset, setTargetOffset] = useState<number | undefined>(undefined);
|
|
|
|
useEffect(() => {
|
|
setTargetOffset(window.innerHeight / 2);
|
|
}, []);
|
|
|
|
return (
|
|
<Anchor
|
|
targetOffset={targetOffset}
|
|
items={[
|
|
{
|
|
key: '1',
|
|
href: '#components-anchor-demo-basic',
|
|
title: 'Basic demo',
|
|
},
|
|
{
|
|
key: '2',
|
|
href: '#components-anchor-demo-static',
|
|
title: 'Static demo',
|
|
},
|
|
{
|
|
key: '3',
|
|
href: '#api',
|
|
title: 'API',
|
|
children: [
|
|
{
|
|
key: '4',
|
|
href: '#anchor-props',
|
|
title: 'Anchor Props',
|
|
},
|
|
{
|
|
key: '5',
|
|
href: '#link-props',
|
|
title: 'Link Props',
|
|
},
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default App;
|