mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove switch statement if there are no props
Summary: Don't generate the switch statement if there are no props Reviewed By: JoshuaGross Differential Revision: D16417803 fbshipit-source-id: 87eda785c836f5e406e27d3c2990ec7f69422bdb
This commit is contained in:
committed by
Facebook Github Bot
parent
d143edc298
commit
58d3cb2fff
+7
-5
@@ -27,9 +27,7 @@ package com.facebook.react.viewmanagers;
|
||||
|
||||
public class ::_CLASSNAME_::<T extends ::_EXTEND_CLASSES_::> {
|
||||
public void setProperty(::_INTERFACE_CLASSNAME_::<T> viewManager, T view, String propName, Object value) {
|
||||
switch (propName) {
|
||||
::_PROP_CASES_::
|
||||
}
|
||||
::_PROP_CASES_::
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -77,10 +75,10 @@ function generatePropCasesString(
|
||||
componentName: string,
|
||||
) {
|
||||
if (component.props.length === 0) {
|
||||
return ' // No props';
|
||||
return '// No props';
|
||||
}
|
||||
|
||||
return component.props
|
||||
const cases = component.props
|
||||
.map(prop => {
|
||||
return `case "${prop.name}":
|
||||
viewManager.set${toSafeJavaString(
|
||||
@@ -89,6 +87,10 @@ function generatePropCasesString(
|
||||
break;`;
|
||||
})
|
||||
.join('\n' + ' ');
|
||||
|
||||
return `switch (propName) {
|
||||
${cases}
|
||||
}`;
|
||||
}
|
||||
|
||||
function getClassExtendString(component): string {
|
||||
|
||||
Reference in New Issue
Block a user