react-json-view-compare icon indicating copy to clipboard operation
react-json-view-compare copied to clipboard

Bug with next.js

Open NicolasBonet opened this issue 4 years ago • 4 comments

Hello,

First of all thanks for the amazing diff tool! I wanted to report a little bug when using next.js:

image

The error comes from the index.js in the lib folder; however, it's encrypted and not easy to fix on my own, so I was wondering if there could be support for SSR in a future release?

Thank you!

NicolasBonet avatar Dec 24 '20 15:12 NicolasBonet

Thank you for your advice. I'll support it later

5SSS avatar Jan 04 '21 10:01 5SSS

you can try this way:

import dynamic from 'next/dynamic';
const DynamicReactCompare = dynamic(() => import('react-json-view-compare'), {
  ssr: false,
});

and notice your react and reac-dom version,this is my package.json file in project:

"dependencies": {
    "next": "10.0.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-json-view-compare": "^1.0.0"
  }

it's works.

5SSS avatar Jan 05 '21 07:01 5SSS

I'm aware dynamic loading can be done, but wanted to inform you in case that you would like to address this out of the box for SSR users :)

NicolasBonet avatar Jan 05 '21 13:01 NicolasBonet

Haha. Okay.

5SSS avatar Jan 07 '21 10:01 5SSS