Giter VIP home page Giter VIP logo

Comments (5)

rchrd2 avatar rchrd2 commented on April 20, 2024 3

Thanks. It would be nice to have an example of including a plugin in the documentation.

At the time, I ended up not using this plugin and doing the following:

export default () => {
  let targetRef = React.createRef();
  React.useEffect(() => {
    new p5(sketch2, targetRef.current);
  }, []);
  return (
    <>
      <Head>
        <script src="/p5/p5.js"></script>
        <script src="/p5-play/lib/p5.play.js"></script>
        <script src="/p5/addons/p5.sound.min.js"></script>
      </Head>
      <div ref={targetRef}></div>
    </>
  );
};

Thanks for the suggestions.

from react.

vennsoh avatar vennsoh commented on April 20, 2024

Yes! I just asked a similar question the other day. If you look at the closed issues that mention how to load p5.sound you will see the solution

from react.

jamesrweb avatar jamesrweb commented on April 20, 2024

@rchrd2 see this comment which is what @vennsoh is referring to.

If that doesn't help, please just reply with a more specific example and question. Hope it helps though!

from react.

vennsoh avatar vennsoh commented on April 20, 2024

Thanks. It would be nice to have an example of including a plugin in the documentation.

At the time, I ended up not using this plugin and doing the following:

export default () => {
  let targetRef = React.createRef();
  React.useEffect(() => {
    new p5(sketch2, targetRef.current);
  }, []);
  return (
    <>
      <Head>
        <script src="/p5/p5.js"></script>
        <script src="/p5-play/lib/p5.play.js"></script>
        <script src="/p5/addons/p5.sound.min.js"></script>
      </Head>
      <div ref={targetRef}></div>
    </>
  );
};

Thanks for the suggestions.

Interesting approach! Do you happen to have a repo to demonstrate how you put all these together? I'd love to learn. Thanks.

from react.

rchrd2 avatar rchrd2 commented on April 20, 2024

Unfortunately this is not for a public repository. I forgot to mention I was using nextjs. So <Head> comes from next-head.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.