Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextjs ReferenceError: window is not defined #3939

Closed
kemisstep opened this issue Sep 26, 2023 · 2 comments
Closed

Nextjs ReferenceError: window is not defined #3939

kemisstep opened this issue Sep 26, 2023 · 2 comments
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions

Comments

@kemisstep
Copy link

Describe the bug

Server Error
ReferenceError: window is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Your Example Website or App

window is not defined

Steps to Reproduce the Bug or Issue

"use client";
import { register } from '@antv/x6-react-shape'

const NodeComponent = () => {
  return (
    <div className="react-node">
      <Progress type="circle" percent={30} width={80} />
    </div>
  )
}

register({
  shape: 'custom-react-node',
  width: 100,
  height: 100,
  component: NodeComponent,
})

graph.addNode({
  shape: 'custom-react-node',
  x: 60,
  y: 100,
})

Expected behavior

正常运行

Screenshots or Videos

No response

Platform

nextjs

Additional context

No response

@NewByVector
Copy link
Contributor

You need to render after the page has loaded, rather than putting render logic in useEffect.

@NewByVector NewByVector added the type: discussion 讨论 Usage questions, guidance, and other discussions label Sep 26, 2023
@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 27, 2024

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions
Projects
None yet
Development

No branches or pull requests

2 participants