Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@babel/preset-typescript": "^7.23.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@testing-library/react": "14.2.0",
"@testing-library/react": "16.3.0",
"@types/react": "^19.1.8",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"babel-jest": "29.7.0",
Expand All @@ -56,9 +57,9 @@
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.2.4",
"pretty-quick": "3.1.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-test-renderer": "19.1.0",
"rollup": "4.9.6",
"typescript": "^5.2.2"
}
Expand Down
2 changes: 1 addition & 1 deletion src/CountUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const CountUp: React.FC<CountUpProps> = (props) => {
update: updateCountUp,
pauseResume,
getCountUp,
}) as JSX.Element | null;
}) as React.JSX.Element | null;
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ export interface CallbackProps {
}

export interface RenderCounterProps extends CountUpApi {
countUpRef: React.RefObject<HTMLElement>;
countUpRef: React.RefObject<HTMLElement | null>;
}
6 changes: 3 additions & 3 deletions src/useCountUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useEventCallback } from './helpers/useEventCallback';
import { CountUp as CountUpJs } from 'countup.js';

export interface UseCountUpProps extends CommonProps, CallbackProps {
ref: string | React.RefObject<HTMLElement>;
ref: string | React.RefObject<HTMLElement | null>;
enableReinitialize?: boolean;
}

Expand Down Expand Up @@ -48,8 +48,8 @@ const useCountUp = (props: UseCountUpProps): CountUpApi => {
...instanceProps
} = useMemo(() => ({ ...DEFAULTS, ...filteredProps }), [props]);

const countUpRef = useRef<CountUpJs>();
const timerRef = useRef<ReturnType<typeof setTimeout>>();
const countUpRef = useRef<CountUpJs>(null);
const timerRef = useRef<ReturnType<typeof setTimeout>>(null);
const isInitializedRef = useRef(false);

const createInstance = useEventCallback(() => {
Expand Down
Loading