Giter VIP home page Giter VIP logo

Comments (4)

halilatilla avatar halilatilla commented on March 28, 2024 2

Just bit by this as well. I'm creating the wrapper component in useEffect(..., []), which should only run on the client side when window exists, but I'm still seeing "window not defined" errors.

I'll try lazy loading and a regular script tag if that fails, but in either case I'm worried about missing out on Intellisense and type checking, and confused about why this would happen when scoped to a client side only block.

You can use with Nextjs like that.

import dynamic from 'next/dynamic'

const P5comp = dynamic( () => import('....'), { ssr: false } )

from react.

jamesrweb avatar jamesrweb commented on March 28, 2024

Hi @SIRHAMY, thanks for raising the issue. As this is a client side project, the assumption is that window will always be defined.

You could attempt lazy loading your modules - this would be my preferred way of doing things.

Alternatively you could just add a regular script tag to your HTML file and link it to our unpkg link for the script, thus avoiding the build step entirely.

from react.

pikeas avatar pikeas commented on March 28, 2024

Just bit by this as well. I'm creating the wrapper component in useEffect(..., []), which should only run on the client side when window exists, but I'm still seeing "window not defined" errors.

I'll try lazy loading and a regular script tag if that fails, but in either case I'm worried about missing out on Intellisense and type checking, and confused about why this would happen when scoped to a client side only block.

from react.

mak1986 avatar mak1986 commented on March 28, 2024
import { P5Instance, Sketch, P5WrapperProps } from 'react-p5-wrapper'
const ReactP5Wrapper = dynamic(() => import('react-p5-wrapper')
    .then(mod => mod.ReactP5Wrapper as any), {
    ssr: false
}) as unknown as React.NamedExoticComponent<P5WrapperProps>

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.