mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
8a49754cda
Summary: Fixes: https://github.com/facebook/react-native/issues/37135 - `substr()` is not part of the core JS since ~2018 - No wonder why no one noticed this :) - Though its supported by modern browsers, its deprecated - Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr ### Why `slice()` and not `substring()`? > Beacuse I like pizza ;) jk The reason, that I'm not using the most obvious alternative `substring()` is; - It _swaps the args_ passed, when; `startIndex > endIndex` —which I think is not a property of _good_ fn and also does not reflects the same in it's name. - It _doesn't support negative args_, which I think reduces flexibility to work with it. - It could lead to more bugs in most of the cases. ### Refecrences: - Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring#differences_between_substring_and_slice - Ref. for `slice()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice - Ref. for `substring()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring ## Changelog: [GENERAL][FIXED] - Refactor: `substr()` is deprecated, using `slice()` instead across RN codebase Pull Request resolved: https://github.com/facebook/react-native/pull/37136 Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_ Reviewed By: christophpurrer Differential Revision: D45477910 Pulled By: jacdebug fbshipit-source-id: 96a80893477599b9a549918924157627b9b0c3f4 |
||
---|---|---|
.. | ||
__tests__ | ||
eslint |