mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add codegen support for DimensionValue for components (#35953)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35953 DimensionValue is a reserved prop type that can be a number or string (such as '50%'). On Java, it will get converted to a YogaValue (converter added to this diff); on C++ it will get converted to a YGValue (converter already exists as it's used in Fabric). Changelog: [Internal][Added] - Add codegen support for DimensionValue for components Reviewed By: cipolleschi Differential Revision: D42650799 fbshipit-source-id: 1d2bc30bbd93837dedbbb4c74f814963c8140957
This commit is contained in:
committed by
Facebook GitHub Bot
parent
97e707d897
commit
d3cc48d9a6
@@ -66,10 +66,12 @@ function getImports(
|
||||
| 'EdgeInsetsPrimitive'
|
||||
| 'ImageSourcePrimitive'
|
||||
| 'PointPrimitive'
|
||||
| 'DimensionPrimitive'
|
||||
| $TEMPORARY$string<'ColorPrimitive'>
|
||||
| $TEMPORARY$string<'EdgeInsetsPrimitive'>
|
||||
| $TEMPORARY$string<'ImageSourcePrimitive'>
|
||||
| $TEMPORARY$string<'PointPrimitive'>,
|
||||
| $TEMPORARY$string<'PointPrimitive'>
|
||||
| $TEMPORARY$string<'DimensionPrimitive'>,
|
||||
) {
|
||||
switch (name) {
|
||||
case 'ColorPrimitive':
|
||||
@@ -86,6 +88,15 @@ function getImports(
|
||||
case 'EdgeInsetsPrimitive':
|
||||
imports.add('import com.facebook.react.bridge.ReadableMap;');
|
||||
return;
|
||||
case 'DimensionPrimitive':
|
||||
if (type === 'delegate') {
|
||||
imports.add(
|
||||
'import com.facebook.react.bridge.DimensionPropConverter;',
|
||||
);
|
||||
} else {
|
||||
imports.add('import com.facebook.yoga.YogaValue;');
|
||||
}
|
||||
return;
|
||||
default:
|
||||
(name: empty);
|
||||
throw new Error(`Invalid ReservedPropTypeAnnotation name, got ${name}`);
|
||||
|
||||
Reference in New Issue
Block a user