Closed VIKTORVAV99 closed 4 months ago
@adrai how do you feel about making some changes that might potentially be breaking changes?
I'm thinking about optional chaining and removing the code here: https://github.com/i18next/react-i18next/blob/92bc14704e447ac38973b804e852c7ccd6c1c15a/src/utils.js#L56-L96
Both of these changes should be supported by the current build config as far as I can tell. Browserslist is configured to only target the default
browsers and the code in question is never used if the peer dependency version of i18next is followed.
same topic like https://github.com/i18next/i18next/pull/2184
What about removing the old code then? That has nothing to do with system compatibility and should be fine as long as the peer versions are followed.
yes, I think 3 years later, we can remove that old code for a future major version (also conditional chaining)... as soon as you "finished" to create other PRs... (non-breaking) I will create a NON-major version, and afterwards we can go for a new major version, ok?
Sounds good!
I'll go through the code a final time and see if I find any other small opportunities to optimise the current code without breaking changes.
Simplifies
hasValidReactChildren
a bit by utilizing Array.isArray, implicit returns and the fact that.every()
can take a function without arguments as it's own argument.This no longer returns false when it's not an array but rather implicitly returns
undefined
which don't affect current functionality as the code it's used in just checks for truthy values.Checklist
npm run test