Skip to content
New issue

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

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

Already on GitHub? # to your account

window 在client / server 渲染访问环境混淆的Erorr #3

Open
carllx opened this issue Aug 18, 2017 · 3 comments
Open

window 在client / server 渲染访问环境混淆的Erorr #3

carllx opened this issue Aug 18, 2017 · 3 comments

Comments

@carllx
Copy link
Owner

carllx commented Aug 18, 2017

CMD:

(node:10336) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 20): ReferenceError: window is not defined

@carllx
Copy link
Owner Author

carllx commented Aug 18, 2017

解决方案:
@evantahler 也遇到这个问题. 参考@arunoda next.js/issues/219#issuecomment-260090020
安装react-no-ssr

@carllx carllx added the bug label Aug 18, 2017
@carllx
Copy link
Owner Author

carllx commented Aug 18, 2017

static html cannot use environment variable

@carllx carllx changed the title client / server 渲染window 访问环境混淆的Erorr window 在client / server 渲染访问环境混淆的Erorr Aug 18, 2017
@carllx
Copy link
Owner Author

carllx commented Aug 18, 2017

componentWillMount. runs on the server and client

Do not use componentWillMount. It runs on the server too.
You need to do this on the client, so use componentDidMount to start the connection.
Then use componentWillUnmount to close the connection. @arunoda issues的回答

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

No branches or pull requests

1 participant