Skip to content

Commit 8d2e011

Browse files
NickGerlemanmeta-codesync[bot]
authored andcommitted
Update codegen to use colorAttribute for ColorPrimitive (facebook#55676)
Summary: Pull Request resolved: facebook#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] Differential Revision: D94052698
1 parent 4f5d291 commit 8d2e011

4 files changed

Lines changed: 10 additions & 28 deletions

File tree

packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ let nativeComponentName = 'ColorPropNativeComponentView';
9797
export const __INTERNAL_VIEW_CONFIG = {
9898
uiViewClassName: \\"ColorPropNativeComponentView\\",
9999
validAttributes: {
100-
tintColor: {
101-
process: require('react-native/Libraries/StyleSheet/processColor').default
102-
}
100+
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
103101
}
104102
};
105103
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
@@ -505,12 +503,8 @@ export const __INTERNAL_VIEW_CONFIG = {
505503
thumbImage: {
506504
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
507505
},
508-
color: {
509-
process: require('react-native/Libraries/StyleSheet/processColor').default
510-
},
511-
thumbTintColor: {
512-
process: require('react-native/Libraries/StyleSheet/processColor').default
513-
},
506+
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
507+
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
514508
point: {
515509
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
516510
}

packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ let nativeComponentName = 'ColorPropNativeComponentView';
9797
export const __INTERNAL_VIEW_CONFIG = {
9898
uiViewClassName: \\"ColorPropNativeComponentView\\",
9999
validAttributes: {
100-
tintColor: {
101-
process: require('react-native/Libraries/StyleSheet/processColor').default
102-
}
100+
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
103101
}
104102
};
105103
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
@@ -505,12 +503,8 @@ export const __INTERNAL_VIEW_CONFIG = {
505503
thumbImage: {
506504
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
507505
},
508-
color: {
509-
process: require('react-native/Libraries/StyleSheet/processColor').default
510-
},
511-
thumbTintColor: {
512-
process: require('react-native/Libraries/StyleSheet/processColor').default
513-
},
506+
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
507+
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
514508
point: {
515509
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
516510
}

packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
7272
switch (typeAnnotation.name) {
7373
case 'ColorPrimitive':
7474
return expression(
75-
"{ process: require('react-native/Libraries/StyleSheet/processColor').default }",
75+
"require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute",
7676
);
7777
case 'ImageSourcePrimitive':
7878
return expression(

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,7 @@ let nativeComponentName = 'ColorPropNativeComponent';
412412
export const __INTERNAL_VIEW_CONFIG = {
413413
uiViewClassName: \\"ColorPropNativeComponent\\",
414414
validAttributes: {
415-
tintColor: {
416-
process: require('react-native/Libraries/StyleSheet/processColor').default
417-
}
415+
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
418416
}
419417
};
420418
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
@@ -1076,12 +1074,8 @@ export const __INTERNAL_VIEW_CONFIG = {
10761074
thumbImage: {
10771075
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
10781076
},
1079-
color: {
1080-
process: require('react-native/Libraries/StyleSheet/processColor').default
1081-
},
1082-
thumbTintColor: {
1083-
process: require('react-native/Libraries/StyleSheet/processColor').default
1084-
},
1077+
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
1078+
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
10851079
point: {
10861080
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
10871081
}

0 commit comments

Comments
 (0)