Skip to content

Added error boundaries to CodeEditor and layout component #96

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

Closed
wants to merge 1 commit into from

Conversation

ishankbahl
Copy link
Contributor

Fix issue #3 , facebook/react#11008 by adding error boundaries to CodeEditor and layout components. Nudging (using alert()) users to whitelist the site in AdBlocker in the alternative UI.

@reactjs-bot
Copy link

Deploy preview ready!

Built with commit e2420ff

https://deploy-preview-96--reactjs.netlify.com

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice start. 😄

I think we need some kind of error UI. Otherwise errors just result in an empty (or mostly empty) page and this is confusing to users and arguably not much better than not handling the error at all.

cc @joecritch in case he has any UI ideas.

render() {
console.log(this.state);
if (this.state.error) {
alert('Error, try to whitelist the site in AdBlocker/Cookie Whitelist');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right way to warn people about this. I think a console.error log would be reasonable though. Maybe something like:

If you're using an ad-blocker or have disabled cookies,
Consider adding this website to the whitelist.

We should also keep in mind that not all errors are caused by this so our wording shouldn't be overly assertive that this is definitely the cause/fix. Users might see an error even if they aren't using adblockers and haven't disabled cookies, and that would be confusing.

@@ -17,6 +17,7 @@ import Remarkable from 'remarkable';
import {LiveProvider, LiveEditor} from '@gaearon/react-live';
import {colors, media} from 'theme';
import MetaTitle from 'templates/components/MetaTitle';
import ErrorBoundary from '../ErrorBoundary';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

import ErrorBoundary from 'components/ErrorBoundary';

@@ -25,6 +25,7 @@ import '../prism-styles';
import 'glamor/reset';
import 'css/reset.css';
import 'css/algolia.css';
import ErrorBoundary from '../components/ErrorBoundary';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

import ErrorBoundary from 'components/ErrorBoundary';

}

render() {
console.log(this.state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this^ 😄

@@ -82,4 +83,4 @@ class Template extends Component {
}
}

export default Template;
export default ErrorBoundary(Template);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors in the template will actually result in a totally empty/white page. This is probably not great. We should show something as a fallback in the browser (in addition to logging error info to the console).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest as the fallback?
Maybe we can use a modal (using react-modal) here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to show a basic error page. It doesn't have to look super pretty. @joecritch or I can pretty it up.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 18, 2017

It's been a while since there was any movement on this PR, and the code it modifies has been changed by subsequent PRs. I'm going to close this for now- but I'm happy to re-review if the PR is updated. Please just ping me by name if there are more changes pushed!

@bvaughn bvaughn closed this Oct 18, 2017
jhonmike pushed a commit to jhonmike/reactjs.org that referenced this pull request Jul 1, 2020
* Translating

* Finishing traslationof lifting state up

* Apply suggestions from code review

Translating codepen links

Co-Authored-By: gustavobini <[email protected]>

* Apply suggestions from code review

Fixing grammar errors

Co-Authored-By: gustavobini <[email protected]>

* Making a few translation corrections

* Delete package-lock.json
BetterZxx pushed a commit to BetterZxx/react.dev that referenced this pull request Mar 21, 2023
…eactjs#96)

* docs(cn): translate content/docs/reference-react-dom.md into Chinese

* change 您 to 你

* modify

* modify

* Update reference-react-dom.md

* Update reference-react-dom.md

* Update reference-react-dom.md
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.

4 participants