localized-strings icon indicating copy to clipboard operation
localized-strings copied to clipboard

Passing undefined to 'formatString' will crash the whole application.

Open MeisiLA opened this issue 6 years ago • 2 comments

Hey!

Because of some changes in our backend we got an undefined for the 2nd parameter (valueForPlaceholder) of formatString and therefore we get a TypeError: undefined is not an object (evaluating 'valuesForPlaceholders[0][matchedKey]') which crashed the whole application.

Strings.formatString(Strings.XXXX, undefined);

This will crash the react-native application.

Maybe it would be possible to add additional checks for it.

rn: 0.58.3 react-native-localization: 2.1.0 react-localization: ^1.0.13

bildschirmfoto 2019-02-06 um 14 47 17

bildschirmfoto 2019-02-06 um 15 04 37

MeisiLA avatar Feb 06 '19 14:02 MeisiLA

Any fix for this ?

razvan-soare avatar Sep 03 '22 11:09 razvan-soare

Hi, you can just pass an empty string instead of undefined like this:

Strings.formatString(Strings.XXXX, undefined || "");

stefalda avatar Sep 04 '22 14:09 stefalda