0

import React, { Component, lazy, Suspense } from 'react';

// import MyComp from './Components/myComp';
const MyComp = lazy(() => import('./components/myComp'));

500 Internal Server Error Error while loading "~/Content/Scripts/dist/server.js": ReferenceError: 'window' is not defined at Anonymous function (server.js:1:1832) -> …o.p="",o.oe=function(e){throw console.error(e),e};var a=window.webpackJsonp=window.webpackJsonp||[],… at Global code (server.js:1:1)

1 Answer 1

0

You have to use loadable https://github.com/gregberge/loadable-components instead of React.lazy. React.lazy doesn't work when you have server side rendering.

import loadable from '@loadable/component'
// This dynamic import will not be processed server-side
const Other = loadable(() => import('./Other'), { ssr: false })
Sign up to request clarification or add additional context in comments.

4 Comments

import React from 'react'; import loadable from '@loadable/component'; import Loading from './Loading'; const LoadableComponent = loadable(() => import('./OtherComponent'), { fallback: <Loading />, }); Still getting same error, also console throws error "Uncaught ReferenceError: jQuery is not defined"
I updated the answer, have you added ssr: false? Not sure how jquery is related to it )
I do not use ssr
I am using react js with asp.net , there is no option ssr in webpack.config.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.