codesandbox / sandpack

A component toolkit for creating live-running code editing experiences, using the power of CodeSandbox.
https://sandpack.codesandbox.io
Apache License 2.0
4.86k stars 344 forks source link

ReferenceError: self is not defined #1074

Open BorisZubchenko opened 8 months ago

BorisZubchenko commented 8 months ago

Bug report

Packages affected

Description of the problem

I can't make the simplest example work with Next.js and Nodebox.

What were you doing when the problem occurred?

What steps can we take to reproduce the problem?

  1. Create a Next.js app.
  2. Install nodebox
  3. Go to page.tsx
  4. Replace the content with:
    
    'use client'

import { Nodebox } from '@codesandbox/nodebox' import { useEffect, useRef } from 'react'

export default function Home() { const iframeRef = useRef(null)

useEffect(() => { const thisEffect = async () => { if (!iframeRef.current) { return }

  const emulator = new Nodebox({
    iframe: iframeRef.current,
  })

  await emulator.connect()
}

thisEffect()

})

return (