ant-design/components/affix/demo/target.tsx
lijianan be92498f15
refactor: rewrite Affix CC => FC (#42674)
* fix

* test

* Update index.ts

* fix

* fix

* fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix

* update docs

* Update components/affix/index.tsx

Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Signed-off-by: lijianan <574980606@qq.com>

* fix

* test: add test case

* Update components/affix/index.zh-CN.md

Co-authored-by: afc163 <afc163@gmail.com>
Signed-off-by: lijianan <574980606@qq.com>

* update demo

---------

Signed-off-by: lijianan <574980606@qq.com>
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: afc163 <afc163@gmail.com>
2023-10-07 18:53:14 +08:00

29 lines
625 B
TypeScript

import React from 'react';
import { Affix, Button } from 'antd';
const containerStyle: React.CSSProperties = {
width: '100%',
height: 100,
overflow: 'auto',
};
const style: React.CSSProperties = {
width: '100%',
height: 1000,
};
const App: React.FC = () => {
const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
return (
<div style={containerStyle} ref={setContainer}>
<div style={style}>
<Affix target={() => container}>
<Button type="primary">Fixed at the top of container</Button>
</Affix>
</div>
</div>
);
};
export default App;