From 026edff33c2f427f17f5cfde761a661630fcd9f4 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Sun, 21 Oct 2018 11:30:21 -0700 Subject: [PATCH] Error boundaries docs shouldn't use class fields --- content/docs/error-boundaries.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/docs/error-boundaries.md b/content/docs/error-boundaries.md index 4d480d46..6591818b 100644 --- a/content/docs/error-boundaries.md +++ b/content/docs/error-boundaries.md @@ -150,14 +150,15 @@ React doesn't need error boundaries to recover from errors in event handlers. Un If you need to catch an error inside event handler, use the regular JavaScript `try` / `catch` statement: -```js{8-12,16-19} +```js{9-13,17-20} class MyComponent extends React.Component { constructor(props) { super(props); this.state = { error: null }; + this.handleClick = this.handleClick.bind(this); } - handleClick = () => { + handleClick() { try { // Do something that could throw } catch (error) {