Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR React problem: _d: document, ^ ReferenceError: document is not defined #454

Closed
ulantiger opened this issue Jul 28, 2020 · 4 comments
Closed
Labels
Milestone

Comments

@ulantiger
Copy link

ulantiger commented Jul 28, 2020

Hello πŸ™‹πŸ»β€β™‚οΈ,

I am trying to use suneditor-react in my react SSR project.

import React, {Components} from "react";
import { Input, Switch , Select, DatePicker } from 'antd';
import { CloseOutlined, CheckOutlined} from '@ant-design/icons';
import moment from 'moment'
import SunEditor from 'suneditor-react';
import 'suneditor/dist/css/suneditor.min.css'

class EditComponent extends Components{
  render(){
    return(
      <div>
        <p> My Other Contents </p>
        if (typeof window !== 'undefined') {
            React.render(<SunEditor lang="en" />
            , document.getElementById("root"))
        }
      </div>
      )
  }
} 

But unfortunately, I have faced the following problem:

D:\softest\reactjs\ssr\node_modules\suneditor-react\dist\main.js:11609
_d: document,
^
ReferenceError: document is not defined
at Module. (D:\softest\reactjs\ssr\node_modules\suneditor-react\dist\main.js:11609:9)
at webpack_require (D:\softest\reactjs\ssr\node_modules\suneditor-react\dist\main.js:21:30)
at D:\softest\reactjs\ssr\node_modules\suneditor-react\dist\main.js:85:18
at Object. (D:\softest\reactjs\ssr\node_modules\suneditor-react\dist\main.js:88:10)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)

Environment: Node v12.16.3, Npm 6.14.4,
packages used:
"dependencies": {
"antd": "^4.4.3",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"html-minifier": "^4.0.0",
"moment": "^2.27.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-html-parser": "^2.0.2",
"react-quill": "^1.3.5",
"react-router-dom": "^5.1.2",
"sqlite3": "^5.0.0",
"suneditor-react": "^2.13.1"
},
"devDependencies": {
"razzle-plugin-scss": "^3.1.5",
"razzle": "latest"
}

@JiHong88 JiHong88 added the bug label Jul 28, 2020
@JiHong88 JiHong88 added this to the 2.33.0 milestone Jul 31, 2020
JiHong88 added a commit that referenced this issue Sep 1, 2020
@JiHong88 JiHong88 closed this as completed Sep 2, 2020
@JiHong88
Copy link
Owner

JiHong88 commented Sep 3, 2020

The 2.33.0 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

@ulantiger
Copy link
Author

I couldn't find a button for reOpening this issue... πŸ€”

@JiHong88
Copy link
Owner

JiHong88 commented Sep 4, 2020

@ulantiger This issue is not resolved?
Please show me a error code and environment.

@ulantiger
Copy link
Author

ulantiger commented Sep 4, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants