fix useWindowSize
This commit is contained in:
parent
00c9410253
commit
e45ef63d41
1 changed files with 2 additions and 1 deletions
|
@ -3,7 +3,8 @@ import React from 'react';
|
|||
|
||||
export function useWindowSize(fn) {
|
||||
const isWindowClient = typeof window === 'object';
|
||||
const [windowSize, setWindowSize] = React.useState(isWindowClient ? window.innerWidth : undefined);
|
||||
const initialState = fn ? fn(window.innerWidth) : window.innerWidth;
|
||||
const [windowSize, setWindowSize] = React.useState(isWindowClient ? initialState : undefined);
|
||||
|
||||
React.useEffect(() => {
|
||||
function setSize() {
|
||||
|
|
Loading…
Reference in a new issue