Yoctol / react-d3-cloud

A word cloud react component built with d3-cloud.
https://yoctol.github.io/react-d3-cloud
MIT License
141 stars 47 forks source link

Document is not defined #154

Open stephanNrich opened 1 year ago

stephanNrich commented 1 year ago

Hey I'm using this library in Nextjs, i've tried to use {typeof window !== undefined} but still getting an error that Document is not defined, any suggestions ?

amir2mi commented 1 year ago

Hi, use this snippet before your main render and return if the env is not browser:

if (typeof window !== 'undefined' || !!process?.browser) return null
ph98 commented 1 year ago

if (typeof document === 'undefined' || typeof window === 'undefined' || !!process?.browser) return null

I'm getting same error after adding this to the component it os not rendering anything. any workaround?