diff --git a/src/useUpdate.ts b/src/useUpdate.ts index e85142d093..b2b6b4c882 100644 --- a/src/useUpdate.ts +++ b/src/useUpdate.ts @@ -1,9 +1,16 @@ import { useCallback, useState } from 'react'; -const incrementParameter = (num: number): number => ++num; +/** + * MIN & MAX safe integers are literals due to no support in IE + */ +const minInt = -1000000000 +const maxInt = 9007199254740991 +const incrementParameter = (num: number): number => { + return num !== maxInt ? (num += 1) : minInt; +} const useUpdate = () => { - const [, setState] = useState(0); + const [, setState] = useState(minInt); // useCallback with empty deps as we only want to define updateCb once return useCallback(() => setState(incrementParameter), []); };