react-d3-cloud icon indicating copy to clipboard operation
react-d3-cloud copied to clipboard

Document is not defined

Open stephanNrich opened this issue 2 years ago • 2 comments

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 ?

stephanNrich avatar Dec 28 '22 08:12 stephanNrich

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

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

amir2mi avatar Dec 31 '22 13:12 amir2mi

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?

ph98 avatar Jul 28 '23 14:07 ph98