Skip to content

Cannot read property "length" of undefined #74

@Kosurij

Description

@Kosurij

If you pass a regExp as second argument in function reactStringReplace you can get error like: Cannot read property "length" of undefined. I think thiss is caused by the work of vanilla replace method.

For example, this code give us an error (it's cyrillic):
const str = 'Справка Форма Ф9';
const re = /(справка[а-я].?(по)? форм[а-я] [ф|Ф]\d)/gi
console.log(str.split(re)); // ["", "Справка Форма Ф9", undefined, ""]

So you cannot get length proprty of undefined. And this error will crush you page.
Example_of_undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions