fix: prevent generate empty regex

This commit is contained in:
EnixCoda 2020-04-03 13:34:46 +08:00
parent aa865d5812
commit 130f42f8a8
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4

View file

@ -59,7 +59,9 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
<VirtualNode
index={index}
style={style}
regex={isValidRegexpSource(searchKey) ? new RegExp(searchKey, 'gi') : undefined}
regex={
searchKey && isValidRegexpSource(searchKey) ? new RegExp(searchKey, 'gi') : undefined
}
onNodeClick={onNodeClick}
renderActions={renderActions}
/>