From f00562f093eab6d7523c09205a806c1633d60b95 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 3 Feb 2022 11:00:19 -0800 Subject: [PATCH 1/6] hopefully fixes issue #1772 reference https://github.com/mdx-js/mdx/issues/1772 --- docs/_component/editor.client.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index fa3831496..95b06b75f 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -119,6 +119,17 @@ export const Editor = ({children}) => { ) const stats = state.file ? statistics(state.file) : {} + //Create a preview component that can handle errors with try-catch block; hopefully catching invalid JS expressions errors + const Preview = useCallback(() => { + try { + return state.file.result(); + } catch (error) { + return (
+        {String(error.message)}
+      
); + } + }, [state.file.result]); + return (
@@ -234,7 +245,7 @@ export const Editor = ({children}) => {
{state.file && state.file.result ? ( - {state.file.result()} + ) : null}
From 0a2a2a3ee95fbee257367aea7c61d6277116db37 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 3 Feb 2022 12:25:01 -0800 Subject: [PATCH 2/6] typo --- docs/_component/editor.client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index 95b06b75f..fb4c79b46 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -128,7 +128,7 @@ export const Editor = ({children}) => { {String(error.message)} ); } - }, [state.file.result]); + }, [state]); return (
From 7c574ee01b078bb10d181a8553dcc6521f24e538 Mon Sep 17 00:00:00 2001 From: homumado <84349818+homumado@users.noreply.github.com> Date: Fri, 4 Feb 2022 03:26:12 -0600 Subject: [PATCH 3/6] Update docs/_component/editor.client.js Co-authored-by: Christian Murphy --- docs/_component/editor.client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index fb4c79b46..05e0134a4 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -119,7 +119,7 @@ export const Editor = ({children}) => { ) const stats = state.file ? statistics(state.file) : {} - //Create a preview component that can handle errors with try-catch block; hopefully catching invalid JS expressions errors + // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors const Preview = useCallback(() => { try { return state.file.result(); From abe17e911fa3a35d0eef2bd05c39b7d8083ba046 Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 4 Feb 2022 10:02:45 -0800 Subject: [PATCH 4/6] code review feedback --- docs/_component/editor.client.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index 05e0134a4..14e660011 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -120,15 +120,16 @@ export const Editor = ({children}) => { const stats = state.file ? statistics(state.file) : {} // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors - const Preview = useCallback(() => { - try { - return state.file.result(); - } catch (error) { - return (
-        {String(error.message)}
-      
); - } - }, [state]); + const Preview = useCallback( + () => { + try { + return + } catch (error) { + return + } + }, + [state] + ) return (
@@ -243,11 +244,7 @@ export const Editor = ({children}) => {
- {state.file && state.file.result ? ( - - - - ) : null} + {state.file && state.file.result ? : null}
From 98855ea786cadb062d241184e3ba568d4424b4ff Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 4 Feb 2022 10:14:13 -0800 Subject: [PATCH 5/6] Not sure why, but this triggers a build error --- docs/_component/editor.client.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index 14e660011..457a32f7e 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -120,16 +120,13 @@ export const Editor = ({children}) => { const stats = state.file ? statistics(state.file) : {} // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors - const Preview = useCallback( - () => { - try { - return - } catch (error) { - return - } - }, - [state] - ) + const Preview = useCallback(() => { + try { + return state.file.result() + } catch (error) { + return + } + }, [state]) return (
From 8afd8970d4dd99415480fcb32c97d4ea074b769c Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 4 Feb 2022 11:58:06 -0800 Subject: [PATCH 6/6] formatting --- docs/_component/editor.client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_component/editor.client.js b/docs/_component/editor.client.js index 457a32f7e..74010106c 100644 --- a/docs/_component/editor.client.js +++ b/docs/_component/editor.client.js @@ -119,7 +119,7 @@ export const Editor = ({children}) => { ) const stats = state.file ? statistics(state.file) : {} - // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors + // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors that ErrorBoundary cannot catch. const Preview = useCallback(() => { try { return state.file.result()