P5-wrapper / react

A wrapper component that allows you to utilise P5 sketches within React apps.

Home Page:https://P5-wrapper.github.io/react/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

p5.sound import issue

qdhoward opened this issue · comments

Hi. I include import "p5/lib/addons/p5.sound" in sketch.js and I get a compile error Line 21: 'loadSound' is not defined no-undef.
Line 21 is: let song = loadSound("/src/test.ogg");
Is there anything I did wrong?
Thank you

Have you tried p.loadSound?

I have tried everything including p.loadSound, p5.loadSound(import p5 from 'p5'). I give up and decide to use other library. I have to say p5 compatibility with front-end framework is not very good.

I had a very similar issue with p5.dom.js. Try importing it from the react-p5-wrapper module folder. It worked for me:

import "react-p5-wrapper/node_modules/p5/lib/addons/p5.dom";