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

React Server Render Error on 2.1.10 #2583

Closed
1 task done
a407121393 opened this issue May 26, 2018 · 5 comments
Closed
1 task done

React Server Render Error on 2.1.10 #2583

a407121393 opened this issue May 26, 2018 · 5 comments

Comments

@a407121393
Copy link

a407121393 commented May 26, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.1.10

Environment

node v9.8 react 16.2.0

Reproduction link

https://github.com/ant-design/ant-design-mobile/blob/master/components/input-item/CustomKeyboard.tsx

Steps to reproduce

React server render not work on version 2.1.10

What is expected?

Node express can start.

What is actually happening?

node ./bin/app.js

D:\GitLab Code\exchanges-site_dev\build\node_modules\antd-mobile\lib\input-item\CustomKeyboard.js:51
var IS_IOS = /iphone|ipad|ipod/i.test(window.navigator.userAgent);
^
ReferenceError: window is not defined
at Object. (D:\GitLab Code\exchanges-site_dev\build\node_modules\antd-mobile\lib\input-item\CustomKeyboard.js:51:39)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (D:\GitLab Code\exchanges-site_dev\build\node_modules\antd-mobile\lib\input-item\CustomInput.js:37:23)
at Module._compile (module.js:652:30)
D:\GitLab Code\exchanges-site_dev\build警告: Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder.

@warmhug
Copy link
Contributor

warmhug commented May 28, 2018

需要判断 typeof window !== 'undefined' 吗?我看 组件代码(包括 antd) 里用到 window 对象属性的地方、很多没特意做这个判断。cc @paranoidjk @yesmeck

@yesmeck
Copy link
Member

yesmeck commented May 28, 2018

@yesmeck
Copy link
Member

yesmeck commented May 28, 2018

componentWillReceiveProps 不会在服务端执行的,所以没关系。其他会在服务端执行的地方要判断。

@warmhug
Copy link
Contributor

warmhug commented May 28, 2018

Ref: #1059 #1077 #1079 #1305

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

No branches or pull requests

4 participants