Created
August 29, 2018 11:08
-
-
Save jonkwheeler/d781edc8af75a17f1b17e6595a9fc2fe to your computer and use it in GitHub Desktop.
Next.js - Window is not defined - Dynamic Import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import dynamic from 'next/dynamic' | |
const ReactJsonNoSSR = dynamic(import('react-json-view'), { | |
ssr: false | |
}) | |
const starWarsJson = { | |
"name": "Luke Skywalker", | |
"height": "172", | |
"mass": "77", | |
"hair_color": "blond", | |
"skin_color": "fair", | |
"eye_color": "blue", | |
"birth_year": "19BBY", | |
"gender": "male", | |
"homeworld": "https://swapi.co/api/planets/1/", | |
"films": [ | |
"https://swapi.co/api/films/2/", | |
"https://swapi.co/api/films/6/", | |
"https://swapi.co/api/films/3/", | |
"https://swapi.co/api/films/1/", | |
"https://swapi.co/api/films/7/" | |
], | |
"species": [ | |
"https://swapi.co/api/species/1/" | |
], | |
"vehicles": [ | |
"https://swapi.co/api/vehicles/14/", | |
"https://swapi.co/api/vehicles/30/" | |
], | |
"starships": [ | |
"https://swapi.co/api/starships/12/", | |
"https://swapi.co/api/starships/22/" | |
], | |
"created": "2014-12-09T13:50:51.644000Z", | |
"edited": "2014-12-20T21:17:56.891000Z", | |
"url": "https://swapi.co/api/people/1/" | |
} | |
class Json extends React.Component{ | |
render(){ | |
return (<ReactJsonNoSSR src={starWarsJson} />) | |
} | |
} | |
export default Json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment