diff --git a/examples/waitTime.tsx b/examples/waitTime.tsx new file mode 100644 index 0000000..1f94f19 --- /dev/null +++ b/examples/waitTime.tsx @@ -0,0 +1,51 @@ +import '../assets/index.less'; +import React, { useState } from 'react'; +import ResizeObserver from '../src'; + +export default function App() { + const [times, setTimes] = React.useState(0); + const [disabled, setDisabled] = React.useState(false); + const textareaRef = React.useRef(null); + const [debounce, setDebounce] = useState(100); + React.useEffect(() => { + console.log('Ref:', textareaRef.current); + setTimeout(() => { + setDebounce(10000); + }, 10000); + }, []); + + const onResize = ({ width, height }: { width: number; height: number }) => { + setTimes(prevTimes => prevTimes + 1); + console.log('Resize:', width, height); + }; + + return ( + +
+
+ + {' >>> '} + Resize times: {times} +
+ debounceļ¼š{debounce} +
+ +