Giter Site home page Giter Site logo

Example does not work. about p5-svelte HOT 6 CLOSED

tonyketcham avatar tonyketcham commented on May 22, 2024 1
Example does not work.

from p5-svelte.

Comments (6)

dogfuntom avatar dogfuntom commented on May 22, 2024 3

I had this in Sapper. Here's how I fixed it:

  1. Remove both p5 and p5-svelte.
  2. Install both p5 and p5-svelte but with -D this time.
  3. Make some changes in the example code:
//import P5 from 'p5-svelte';
import { onMount } from "svelte";

let P5;

onMount(async () => {
	const module = await import("p5-svelte");
	P5 = module.default;
});

and

<!-- <P5 {sketch} /> -->
<svelte:component this={P5} {sketch} />

from p5-svelte.

rawoke083 avatar rawoke083 commented on May 22, 2024 2

I had this in Sapper. Here's how I fixed it:

  1. Remove both p5 and p5-svelte.
  2. Install both p5 and p5-svelte but with -D this time.
  3. Make some changes in the example code:
//import P5 from 'p5-svelte';
import { onMount } from "svelte";

let P5;

onMount(async () => {
	const module = await import("p5-svelte");
	P5 = module.default;
});

and

<!-- <P5 {sketch} /> -->
<svelte:component this={P5} {sketch} />

Wow good(clever) work-around :)

from p5-svelte.

tonyketcham avatar tonyketcham commented on May 22, 2024 2

@dogfuntom Thanks! I just updated the documentation!

from p5-svelte.

tonyketcham avatar tonyketcham commented on May 22, 2024

@rawoke083 when I'm following the example in a mac environment, npm install p5-svelte installs p5 as a peer dependency and this error doesn't occur.

Yet trying the same on Code Sandbox, the peer dependencies aren't being respected for some reason, so adding p5 as a dependency resolves the error: https://codesandbox.io/s/p5-svelte-demo-zvlcm?file=/App.svelte

Perhaps that's the case here - have you tried npm install p5 -D?

from p5-svelte.

rawoke083 avatar rawoke083 commented on May 22, 2024

Perhaps that's the case here - have you tried npm install p5 -D?

Nah still getting same error... weird :(

from p5-svelte.

tonyketcham avatar tonyketcham commented on May 22, 2024

Are you installing to a fresh svelte project using the official template?

Also what environment are you running? Unfortunately, I've been unable to reproduce this issue

from p5-svelte.

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.