mirror of
https://github.com/react/react-native.git
synced 2026-09-29 16:58:04 +08:00
Handle component name
Summary: In order to generate the view configs, we need to know the name of the component used in: ``` ReactNativeViewConfigRegistry.register( 'RCTNativeComponent', // <------- this name () => BooleanPropNativeComponentViewConfig, ); ``` For this, we'll use `component.name` in the schema (see fixture updates). Doing this would break the native code we generate though, since that code has the RCT stripped. So this diff adds support to mirror the native stripping of 'RCT' for generated native code Reviewed By: TheSavior Differential Revision: D15320422 fbshipit-source-id: be1ab9964078df2c7bc6e41462776f00b94b104f
This commit is contained in:
committed by
Facebook Github Bot
parent
382846aefd
commit
ed61a3b5f9
@@ -92,6 +92,7 @@ export type EventTypeShape = $ReadOnly<{|
|
||||
|
||||
export type ComponentShape = $ReadOnly<{|
|
||||
interfaceOnly?: boolean,
|
||||
isDeprecatedPaperComponentNameRCT?: boolean,
|
||||
extendsProps: $ReadOnlyArray<{|
|
||||
type: 'ReactNativeBuiltInType',
|
||||
knownTypeName: 'ReactNativeCoreViewProps',
|
||||
|
||||
@@ -71,7 +71,7 @@ const ::_COMPONENT_NAME_::ViewConfig = VIEW_CONFIG;
|
||||
verifyComponentAttributeEquivalence('::_COMPONENT_NAME_::', ::_COMPONENT_NAME_::ViewConfig);
|
||||
|
||||
ReactNativeViewConfigRegistry.register(
|
||||
'::_COMPONENT_NAME_::',
|
||||
'::_COMPONENT_NAME_WITH_COMPAT_SUPPORT_::',::_COMPAT_COMMENT_::
|
||||
() => ::_COMPONENT_NAME_::ViewConfig,
|
||||
);
|
||||
|
||||
@@ -265,10 +265,22 @@ module.exports = {
|
||||
.map(componentName => {
|
||||
const component = components[componentName];
|
||||
|
||||
const replacedTemplate = componentTemplate.replace(
|
||||
/::_COMPONENT_NAME_::/g,
|
||||
componentName,
|
||||
);
|
||||
const compatabilityComponentName = `${
|
||||
component.isDeprecatedPaperComponentNameRCT ? 'RCT' : ''
|
||||
}${componentName}`;
|
||||
|
||||
const replacedTemplate = componentTemplate
|
||||
.replace(/::_COMPONENT_NAME_::/g, componentName)
|
||||
.replace(
|
||||
/::_COMPONENT_NAME_WITH_COMPAT_SUPPORT_::/g,
|
||||
compatabilityComponentName,
|
||||
)
|
||||
.replace(
|
||||
/::_COMPAT_COMMENT_::/g,
|
||||
component.isDeprecatedPaperComponentNameRCT
|
||||
? ' // RCT prefix present for paper support'
|
||||
: '',
|
||||
);
|
||||
|
||||
const replacedSource: string = j
|
||||
.withParser('flow')(replacedTemplate)
|
||||
|
||||
@@ -18,6 +18,7 @@ const INTERFACE_ONLY: SchemaType = {
|
||||
components: {
|
||||
InterfaceOnlyComponent: {
|
||||
interfaceOnly: true,
|
||||
isDeprecatedPaperComponentNameRCT: true,
|
||||
extendsProps: [
|
||||
{
|
||||
type: 'ReactNativeBuiltInType',
|
||||
|
||||
+1
-1
@@ -523,7 +523,7 @@ const InterfaceOnlyComponentViewConfig = {
|
||||
verifyComponentAttributeEquivalence('InterfaceOnlyComponent', InterfaceOnlyComponentViewConfig);
|
||||
|
||||
ReactNativeViewConfigRegistry.register(
|
||||
'InterfaceOnlyComponent',
|
||||
'RCTInterfaceOnlyComponent', // RCT prefix present for paper support
|
||||
() => InterfaceOnlyComponentViewConfig,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user