Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.5] Bug 1845125: Use undefined as default value for width hook #5689

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/public/components/utils/ref-width-hook.ts
Expand Up @@ -2,12 +2,12 @@ import { useEffect, useRef, useState } from 'react';

export const useRefWidth = () => {
const ref = useRef<HTMLDivElement>(null);
const [width, setWidth] = useState(0);
const [width, setWidth] = useState<number>();

const clientWidth = ref?.current?.clientWidth ?? 0;
const clientWidth = ref?.current?.clientWidth;

useEffect(() => {
const handleResize = () => setWidth(ref?.current?.clientWidth ?? 0);
const handleResize = () => setWidth(ref?.current?.clientWidth);
window.addEventListener('resize', handleResize);
window.addEventListener('sidebar_toggle', handleResize);
return () => {
Expand Down