Skip to content

Commit 7e1969b

Browse files
committed
Fix RegExp errors from the console
Fixes codesandbox#2245
1 parent 74f7ce6 commit 7e1969b

File tree

1 file changed

+10
-1
lines changed
  • packages/app/src/app/components/Preview/DevTools/Console

1 file changed

+10
-1
lines changed

packages/app/src/app/components/Preview/DevTools/Console/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ class Console extends React.Component<StyledProps> {
214214
}
215215

216216
const { messages, filter, searchKeywords } = this.state;
217+
218+
let searchKeywordsHasError = false;
219+
220+
try {
221+
new RegExp(searchKeywords); // eslint-disable-line
222+
} catch (e) {
223+
searchKeywordsHasError = true;
224+
}
225+
217226
return (
218227
<Container>
219228
<Messages
@@ -226,7 +235,7 @@ class Console extends React.Component<StyledProps> {
226235
variant={this.props.theme.light ? 'light' : 'dark'}
227236
styles={inspectorTheme(this.props.theme)}
228237
filter={filter}
229-
searchKeywords={searchKeywords}
238+
searchKeywords={searchKeywordsHasError ? '' : searchKeywords}
230239
/>
231240
</Messages>
232241
<Input evaluateConsole={this.evaluateConsole} />

0 commit comments

Comments
 (0)