Skip to content

Commit c3381af

Browse files
authoredAug 21, 2021
fix: responsive container (#2622)
1 parent 213d4a9 commit c3381af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/component/ResponsiveContainer.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const ResponsiveContainer = forwardRef(
4949
const containerRef = useRef<HTMLDivElement>(null);
5050
useImperativeHandle(ref, () => containerRef, [containerRef]);
5151

52-
let mounted: boolean;
52+
const mounted = useRef<boolean>(false);
5353

5454
const getContainerSize = () => {
5555
if (!containerRef.current) {
@@ -63,7 +63,7 @@ export const ResponsiveContainer = forwardRef(
6363
};
6464

6565
const updateDimensionsImmediate = () => {
66-
if (!mounted) {
66+
if (!mounted.current) {
6767
return;
6868
}
6969

@@ -139,7 +139,7 @@ export const ResponsiveContainer = forwardRef(
139139
};
140140

141141
useEffect(() => {
142-
mounted = true;
142+
mounted.current = true;
143143

144144
const size = getContainerSize();
145145

@@ -148,7 +148,7 @@ export const ResponsiveContainer = forwardRef(
148148
}
149149

150150
return () => {
151-
mounted = false;
151+
mounted.current = false;
152152
};
153153
}, []);
154154

0 commit comments

Comments
 (0)
Please sign in to comment.