FormidableLabs / react-live

A flexible playground for live editing React components
https://commerce.nearform.com/open-source/react-live/
MIT License
4.29k stars 240 forks source link

ErrorBoundary(...): Nothing was returned from render #186

Open paul-pro opened 4 years ago

paul-pro commented 4 years ago

Hi! Looks like when you use undefined JS object or its method, error will be normally caught: e.g. code= {'some.method'} will correctly render error with ReferenceError: some is not defined

But when you try to reference some undefined method of real object it will cause internal error which will break whole page. See reproduction on code sandbox: https://codesandbox.io/s/react-live-bug-mqbu7 (btw, code={'window'} will also blow up page)

I found this bug while live editing input code in mdx environment.

sanket03 commented 4 years ago

Facing same issue, any updates on this?

Downchuck commented 3 years ago

The error boundary class needs:

static getDerivedStateFromError(error) {
    return { hasError: true };
}

I still had a very rough time, but that's one of the issues around evalCode.

lex111 commented 3 years ago

@jpdriver please include a fix for this issue in v3.