react-animated-numbers: Next.js v13.4.12 - not working
I import package as it says in doc
import dynamic from "next/dynamic";
const AnimatedNumbers = dynamic(() => import("react-animated-numbers"), {
ssr: false,
});
my usage:
<AnimatedNumbers
animateToNumber={item.number}
configs={(number, index) => {
return {
mass: 1,
tension: 230 * (index + 1),
friction: 140,
};
}}
/>
but nothing changes, numbers stay on zero.
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 16 (4 by maintainers)
@arxkdev , I used the following to import and it worked like charm for me
“use client” import dynamic from “next/dynamic”; const AnimatedNumbers = dynamic(() => import(“react-animated-numbers”), { ssr: false, });
and then you can use as normal component
<AnimatedNumbers includeComma transitions={(index) => ({ type: “spring”, duration: index + 0.3, })} animateToNumber={1000} />
Tried a fresh next.js project with 13.5.1 and it does not work. I get the following error:
I have marked the component as client-only with the
"use client";directive. You can take a look at the project on stackblitz@VikasOodles23 This worked. Thanks!