Bugs in normalize text algorithm
See original GitHub issueExplain what you did
Call normalize(1) in iPhone 5. It will return 0.95.
Expected behavior
It should be 1 according to the comments in source codes.
Describe the bug
The reason is that iPhone 5 has a 320x568 screen, which will trigger the first if statement in src/helpers/normalizeText.js.
What’s more, in other cases like pixelRatio >= 3 && pixelRatio < 3.5 and pixelRatio >= 3.5, the condition of the first if statement includes deviceWidth=360, but pixelRatio >= 2 && pixelRatio < 3 does not. It looks like strange.
At last, would you mind adding tests like https://github.com/gitpoint/git-point/pull/899 for this file?
// iphone 5s and older Androids
if (deviceWidth < 360) {
return size * 0.95;
}
// iphone 5
if (deviceHeight < 667) {
return size;
// iphone 6-6s
}
To Reproduce
See https://github.com/gitpoint/git-point/pull/899.
Screenshots
None.
Your Environment (please complete the following information):
| software | version |
|---|---|
| react-native-elements | any |
| react-native | any |
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)

Top Related StackOverflow Question
As a side note, to my knowledge regexs are only expensive when
.*is overused and the likelyhood of the regex having to backtrack increases. That regex looks fairly straight forward and not too intense of a process. Also, that regex is only run once. If the regex was being run every time it needed to scale a number, I’d agree that that would intense.I’m wondering if instead of trying to fix this rather complicated algorithm we instead change to using this library instead: https://github.com/NewBieBR/react-native-normalize thoughts? This would likely require a major revision bump though.