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

fix(ssr): clone extraProps in SSR HOC #4362

Merged
merged 1 commit into from
Apr 2, 2020
Merged

fix(ssr): clone extraProps in SSR HOC #4362

merged 1 commit into from
Apr 2, 2020

Conversation

eligao
Copy link

@eligao eligao commented Apr 2, 2020

Checklist
  • npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change
  • fixes "object is not extensible" in HOC getInitialProps
    image

@codecov
Copy link

codecov bot commented Apr 2, 2020

Codecov Report

Merging #4362 into 2.x will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              2.x    #4362   +/-   ##
=======================================
  Coverage   40.80%   40.80%           
=======================================
  Files         284      284           
  Lines        8079     8079           
  Branches     1968     1968           
=======================================
  Hits         3297     3297           
+ Misses       4409     4402    -7     
- Partials      373      380    +7     
Impacted Files Coverage Δ
packages/umi/src/renderRoutes.js 92.47% <ø> (ø)
packages/umi-plugin-ui/src/bubble/index.jsx 0.00% <0.00%> (ø)
...kages/umi-plugin-ui/src/plugins/dashboard/index.ts 0.00% <0.00%> (ø)
...s/umi-build-dev/src/plugins/commands/block/util.ts 33.11% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5700e1...69b5c4c. Read the comment docs.

@eligao
Copy link
Author

eligao commented Apr 2, 2020

image
Brief explanation:

  1. here extraProps is passed as a reference, all the way from the props of the root RouteWrapper, and react props are not modifiable
  2. in the case when WrappedComponent.getInitialProps returns the provided prevInitialProps: extraProps directly
  3. here we would be attempting to add a property to the immutable object, which throws TypeError: can't define property "x": "obj" is not extensible

@ycjcl868 ycjcl868 added pr(bug) and removed pr(chore) labels Apr 2, 2020
@ycjcl868 ycjcl868 merged commit 4eb688a into umijs:2.x Apr 2, 2020
@eligao eligao deleted the fix-ssr-object-not-extensible branch April 2, 2020 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants