Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound not playing on Recat-typescript #121

Open
Souravrao-31 opened this issue Dec 1, 2022 · 1 comment
Open

Sound not playing on Recat-typescript #121

Souravrao-31 opened this issue Dec 1, 2022 · 1 comment

Comments

@Souravrao-31
Copy link

Souravrao-31 commented Dec 1, 2022

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

@u00t
Copy link

u00t commented Dec 6, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants