Skip to content

Commit

Permalink
Use undefined as default value for width hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rawagner committed Jun 1, 2020
1 parent f692810 commit e7a6afd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/public/components/utils/ref-width-hook.ts
Original file line number Diff line number Diff line change
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

0 comments on commit e7a6afd

Please sign in to comment.