Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

normalize-color accepts functional colors with surrounding junk

Open
#58,495 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, react-native
Domain
mobile

Research direction

Start with the functional color matchers in @react-native/normalize-colors and reproduce the listed rgb, rgba, and spaced-hex cases using the linked Snack. Done means inputs with surrounding junk return null while valid functional colors continue to produce non-null values; the issue also links fix PR #58496.

Written by the indexing model from the issue text.

Description

Needs: Attention Needs: Repro
Description

@react-native/normalize-colors fully anchors hex matchers (^…$) but not rgb/rgba/hsl/hsla/hwb. Substring matches are therefore accepted:

normalizeColor('xxrgb(1, 2, 3)yy') // => 0x010203ff (unexpected)
normalizeColor('rgba(1,2,3,0.5)extra') // => non-null (unexpected)
normalizeColor(' #fff ') // => null (hex correctly rejects)
Steps to reproduce
  1. Open the Snack: https://snack.expo.dev/rykV9Sq-NOSJg8KWXawiP
  2. Look at rows for xxrgb(1, 2, 3)yy, rgb(1, 2, 3)yy, and rgba(1,2,3,0.5)extra
  3. Observe non-null processColor values and painted swatches (bug). Spaced hex #fff correctly stays null.
React Native Version

main / latest (package @react-native/normalize-colors, used by processColor)

Affected Platforms
  • Runtime - Android
  • Runtime - iOS
  • Runtime - Web
  • Other (please specify): pure JS @react-native/normalize-colors
Output of npx @react-native-community/cli info

N/A — reproducible via Snack / unit package without a local app install.

Stacktrace or Logs

N/A (incorrect non-null return value, no crash)

MANDATORY Reproducer

https://snack.expo.dev/rykV9Sq-NOSJg8KWXawiP

Screenshots and Videos

N/A

Fix PR: https://github.com/facebook/react-native/pull/58496

Dominant language
C++
Stars
127k
Forks
25.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react/react-native

All issues in react/react-native

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.