From 0ce27908b7cc4581f20935be263f900edd937f32 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 25 Feb 2026 08:14:29 -0800 Subject: [PATCH] Update GenerateViewConfigJs for native CSS parsing (#55676) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55676 Change `GenerateViewConfigJs.js` to emit `require('.../ReactNativeStyleAttributes').colorAttribute` for `ColorPrimitive` props instead of the inline `{process: require('.../processColor').default}`. This ensures generated ViewConfigs use the same gated attribute as handwritten ones. Changelog: [Internal] Reviewed By: lenaic Differential Revision: D94052698 fbshipit-source-id: aa4821364062807b0ae862379d236a2f458c9c53 --- .../__snapshots__/GenerateViewConfigJs-test.js.snap | 12 +++--------- .../__snapshots__/GenerateViewConfigJs-test.js.snap | 12 +++--------- .../generators/components/GenerateViewConfigJs.js | 2 +- .../__snapshots__/GenerateViewConfigJs-test.js.snap | 12 +++--------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap index 0024445cbb2..bb0a9098fc0 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -97,9 +97,7 @@ let nativeComponentName = 'ColorPropNativeComponentView'; export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: \\"ColorPropNativeComponentView\\", validAttributes: { - tintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - } + tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute } }; export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); @@ -505,12 +503,8 @@ export const __INTERNAL_VIEW_CONFIG = { thumbImage: { process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource')) }, - color: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, - thumbTintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, + color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, + thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, point: { diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer')) } diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap index e204e30a267..054bd1a003b 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -97,9 +97,7 @@ let nativeComponentName = 'ColorPropNativeComponentView'; export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: \\"ColorPropNativeComponentView\\", validAttributes: { - tintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - } + tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute } }; export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); @@ -505,12 +503,8 @@ export const __INTERNAL_VIEW_CONFIG = { thumbImage: { process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource')) }, - color: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, - thumbTintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, + color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, + thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, point: { diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer')) } diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index 6993f4b893b..05d49fcf08a 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -72,7 +72,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) { switch (typeAnnotation.name) { case 'ColorPrimitive': return expression( - "{ process: require('react-native/Libraries/StyleSheet/processColor').default }", + "require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute", ); case 'ImageSourcePrimitive': return expression( diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index a22f3421309..7b3d95c3713 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -412,9 +412,7 @@ let nativeComponentName = 'ColorPropNativeComponent'; export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: \\"ColorPropNativeComponent\\", validAttributes: { - tintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - } + tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute } }; export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); @@ -1076,12 +1074,8 @@ export const __INTERNAL_VIEW_CONFIG = { thumbImage: { process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource')) }, - color: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, - thumbTintColor: { - process: require('react-native/Libraries/StyleSheet/processColor').default - }, + color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, + thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute, point: { diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer')) }