FIX[react-community-cli-plugin]: Node v20+ Text Style Error in Metro #53556
+37
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This pull request fixes a Node.js 20+ compatibility issue with the
styleText
utility function in the React Native CLI. In Node.js 20+, passing an array of styles tostyleText
throws anERR_INVALID_ARG_VALUE
error. The fix introduces acompatibleStyleText
helper function that detects the Node.js version and handles array styles by applying them individually for Node.js 20+, while maintaining backward compatibility with older versions.Additionally, this PR adds proper Flow type annotations to resolve missing annotation linting errors in the affected files.
Changelog:
[GENERAL] [FIXED] - Fix Node.js 20+ compatibility issue with styleText array formatting in CLI
Test Plan:
1. Reproduce the Node.js 20+ Issue:
Expected output on Node.js 20+:
2. Test the Fix:
Expected output on Node.js 20+:
3. Manual Testing:
Node.js 20+ Environment:
node --version # Verify Node.js 20+ npx react-native start
ERR_INVALID_ARG_VALUE
errorsNode.js <20 Environment:
nvm use 18 # or any version < 20 npx react-native start
4. Flow Type Checking:
Code Changes:
compatibleStyleText
function in that detects Node.js version and handles array styles appropriatelyExpected Behavior:
['bold', 'inverse']
are applied individually via multiplestyleText
callsstyleText
call with array