File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,15 @@ export const Editor = ({children}) => {
119
119
)
120
120
const stats = state . file ? statistics ( state . file ) : { }
121
121
122
+ // Create a preview component that can handle errors with try-catch block; for catching invalid JS expressions errors that ErrorBoundary cannot catch.
123
+ const Preview = useCallback ( ( ) => {
124
+ try {
125
+ return state . file . result ( )
126
+ } catch ( error ) {
127
+ return < FallbackComponent error = { error } />
128
+ }
129
+ } , [ state ] )
130
+
122
131
return (
123
132
< div >
124
133
< Tabs className = "frame" >
@@ -232,11 +241,7 @@ export const Editor = ({children}) => {
232
241
< TabPanel >
233
242
< noscript > Enable JavaScript for the rendered result.</ noscript >
234
243
< div className = "frame-body frame-body-box-fixed-height frame-body-box" >
235
- { state . file && state . file . result ? (
236
- < ErrorBoundary FallbackComponent = { FallbackComponent } >
237
- { state . file . result ( ) }
238
- </ ErrorBoundary >
239
- ) : null }
244
+ { state . file && state . file . result ? < Preview /> : null }
240
245
</ div >
241
246
</ TabPanel >
242
247
< TabPanel >
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Feb 7, 2022
Successfully deployed to the following URLs: