We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 729df9c commit f7b1523Copy full SHA for f7b1523
README.md
@@ -77,3 +77,23 @@ return (
77
```
78
79
The above example will report the `clientWidth` rather than the default `offsetWidth` and `offsetHeight`.
80
+
81
+## React to size variations
82
83
+For completeness, below you can find an example to show how to make your code react to size variations using React Hooks:
84
85
+``jsx
86
+const App = () => {
87
+ const [resizeListener, sizes] = useResizeAware(customReporter);
88
89
+ React.useEffect(() => {
90
+ console.log('Do something with the new size values');
91
+ }, [sizes.width, sizes.height]);
92
93
+ return (
94
+ <div style={{ position: 'relative' }}>
95
+ {resizeListener}
96
+ Your content here.
97
+ </div>
98
+ );
99
+}
0 commit comments