alibaba / rax

🐰 Rax is a progressive framework for building universal application. https://rax.js.org
Other
7.99k stars 627 forks source link

[BUG] The input argument of `getDerivedStateFromError` of class component is missing #2211

Closed Clarence-pan closed 3 years ago

Clarence-pan commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

The input argument of getDerivedStateFromError of class component is missing.

To Reproduce Steps to reproduce the behavior:

  1. Go to example codesandbox: https://codesandbox.io/s/heuristic-raman-3tv8l?file=/src/index.js
  2. Click on "Click ME to trigger Error!" in the right browser
  3. Now see the error, but it's "undefined"!
  4. You can also open the right console, the console log will be "getDerivedStateFromError: undefined"

Expected behavior After click on "Click ME to trigger Error!", the error message should be "test error" not "undefined" -- The input argument of getDerivedStateFromError should be the thrown error with message "test error"

Screenshots If applicable, add screenshots to help explain your problem.

image

(please complete the following information)

Additional context After I searched getDerivedStateFromError in the source code of Rax, I found the following code: image

--https://github.com/alibaba/rax/blob/36ba0537eb4649f259abb8d96e2c72dc4985794a/packages/rax/src/vdom/performInSandbox.js#L42

Maybe this bug is very easy to fix