Skip to content

Commit 5a31c48

Browse files
committed
use break statement to stop the loop
1 parent 6398ed8 commit 5a31c48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

draft-js-mention-plugin/src/mentionSuggestionsStrategy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const findWithRegex = (regex, contentBlock, callback) => {
1515
let prevLastIndex = regex.lastIndex;
1616

1717
// Go through all matches in the text and return the indices to the callback
18-
// Force update regex's lastIndex to avoid Infinite loop
18+
// Break the loop if lastIndex is not changed
1919
while ((matchArr = regex.exec(text)) !== null) { // eslint-disable-line
2020
if (regex.lastIndex === prevLastIndex) {
21-
regex.lastIndex += 1; // eslint-disable-line no-param-reassign
21+
break;
2222
}
2323
prevLastIndex = regex.lastIndex;
2424
start = nonEntityStart + matchArr.index;

0 commit comments

Comments
 (0)