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

feat: ssr getInitialProps add req, res params #2938

Merged
merged 2 commits into from Aug 9, 2019

Conversation

ycjcl868
Copy link
Contributor

@ycjcl868 ycjcl868 commented Aug 5, 2019

Close #2844.

@ycjcl868 ycjcl868 changed the title feat: render req, res option feat: ssr getInitialProps add req, res option Aug 5, 2019
@ycjcl868 ycjcl868 changed the title feat: ssr getInitialProps add req, res option feat: ssr getInitialProps add req, res params Aug 5, 2019
@sorrycc
Copy link
Member

sorrycc commented Aug 5, 2019

res 用不到吧?

@ycjcl868
Copy link
Contributor Author

ycjcl868 commented Aug 6, 2019

可以做一些跳转和错误处理:

import React from 'react'

export default class extends React.Component {
  static async getInitialProps({ res }) {
    if (res) {
       res.statusCode = 404
       res.end('Not found')
       return
   }
  }
}

@ycjcl868 ycjcl868 force-pushed the feat-ssr-getInitialProps-opts branch from 2bbe873 to fd84a42 Compare August 6, 2019 01:44
@coveralls
Copy link

coveralls commented Aug 6, 2019

Pull Request Test Coverage Report for Build 4975

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 25 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.05%) to 33.613%

Files with Coverage Reduction New Missed Lines %
packages/umi-build-dev/lib/plugins/commands/ui/src/app.js 10 0.0%
packages/umi-build-dev/src/plugins/history.js 15 0.0%
Totals Coverage Status
Change from base Build 4973: -0.05%
Covered Lines: 1475
Relevant Lines: 4385

💛 - Coveralls

@sorrycc sorrycc merged commit d910966 into master Aug 9, 2019
@sorrycc sorrycc deleted the feat-ssr-getInitialProps-opts branch August 9, 2019 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getInitialProps钩子入参重定向问题建议
3 participants