Sound not playing on Recat-typescript
Souravrao-31 opened this issue · comments
Hello,
I would love to use this amazing tool, but I'm not able to use with React+Typescript (I've just started to learn them). Tried multiple times, but I've encountered with 2 main error.
I'm not able to import from my folder the mp3 as I get this TS error : Cannot find module or its corresponding type declarations.ts(2307)
And after assigning audio its not playing
code......................
import useSound from "use-sound";
import notificationSoundmp3 from "../../Utils/assets/sound/notification.mp3";
const [play] = useSound(notificationSoundmp3, { volume: 0.5 });
const handleTestButton = () => { setOpenTestModal(!openTestModal); play(); };
I hope someone can help me
Hello, @Souravrao-31
Add this code to .d.ts
file in src
folder.
declare module "*.mp3" {
const src: string;
export default src;
}
I hope this will help you.