mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Emit code with different react-native versions
This commit is contained in:
parent
5dcc94deb5
commit
305d132a48
@ -88,7 +88,7 @@ function getOptions(options) {
|
|||||||
|
|
||||||
function reactImport(options) {
|
function reactImport(options) {
|
||||||
if (options.native) {
|
if (options.native) {
|
||||||
return 'react-native';
|
return reactNativeSupport[options.nativeTargetVersion].react.module;
|
||||||
}
|
}
|
||||||
if (_.includes(['0.14.0', '0.15.0', '15.0.0', '15.0.1'], options.targetVersion)) {
|
if (_.includes(['0.14.0', '0.15.0', '15.0.0', '15.0.1'], options.targetVersion)) {
|
||||||
return 'react';
|
return 'react';
|
||||||
@ -247,7 +247,8 @@ function handleStyleProp(val, node, context) {
|
|||||||
*/
|
*/
|
||||||
function convertTagNameToConstructor(tagName, context) {
|
function convertTagNameToConstructor(tagName, context) {
|
||||||
if (context.options.native) {
|
if (context.options.native) {
|
||||||
return _.includes(reactNativeSupport[context.options.nativeTargetVersion], tagName) ? 'React.' + tagName : tagName;
|
const targetSupport = reactNativeSupport[context.options.nativeTargetVersion];
|
||||||
|
return _.includes(targetSupport.components, tagName) ? `${targetSupport.reactNative.name}.${tagName}` : tagName;
|
||||||
}
|
}
|
||||||
let isHtmlTag = _.includes(reactDOMSupport[context.options.targetVersion], tagName);
|
let isHtmlTag = _.includes(reactDOMSupport[context.options.targetVersion], tagName);
|
||||||
if (reactSupport.shouldUseCreateElement(context)) {
|
if (reactSupport.shouldUseCreateElement(context)) {
|
||||||
@ -268,6 +269,12 @@ function defaultContext(html, options, reportContext) {
|
|||||||
{moduleName: options.reactImportPath, alias: 'React', member: '*'},
|
{moduleName: options.reactImportPath, alias: 'React', member: '*'},
|
||||||
{moduleName: options.lodashImportPath, alias: '_', member: '*'}
|
{moduleName: options.lodashImportPath, alias: '_', member: '*'}
|
||||||
];
|
];
|
||||||
|
if (options.native) {
|
||||||
|
const targetSupport = reactNativeSupport[options.nativeTargetVersion];
|
||||||
|
if (targetSupport.reactNative.module !== targetSupport.react.module) {
|
||||||
|
defaultDefines.splice(0, 0, {moduleName: targetSupport.reactNative.module, alias: targetSupport.reactNative.name, member: '*'});
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
boundParams: [],
|
boundParams: [],
|
||||||
injectedFunctions: [],
|
injectedFunctions: [],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user