Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
[Fix] isReactComponent on native arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
akxcv committed Jun 22, 2018
1 parent 30ab626 commit 22567e7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/vuera.cjs.js
Expand Up @@ -407,7 +407,7 @@ var ReactWrapper = {
function isReactComponent(component) {
if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object') {
return false;
} else if (typeof component === 'function' && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
} else if (typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
return false;
} else {
return true;
Expand Down
2 changes: 1 addition & 1 deletion dist/vuera.es.js
Expand Up @@ -401,7 +401,7 @@ var ReactWrapper = {
function isReactComponent(component) {
if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object') {
return false;
} else if (typeof component === 'function' && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
} else if (typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
return false;
} else {
return true;
Expand Down
2 changes: 1 addition & 1 deletion dist/vuera.iife.js
Expand Up @@ -404,7 +404,7 @@ var ReactWrapper = {
function isReactComponent(component) {
if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object') {
return false;
} else if (typeof component === 'function' && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
} else if (typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.name.startsWith('Vue')) {
return false;
} else {
return true;
Expand Down
1 change: 1 addition & 0 deletions src/utils/isReactComponent.js
Expand Up @@ -3,6 +3,7 @@ export default function isReactComponent (component) {
return false
} else if (
typeof component === 'function' &&
component.prototype &&
component.prototype.constructor.super &&
component.prototype.constructor.super.name.startsWith('Vue')
) {
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/ReactFunctionalComponent.js
@@ -0,0 +1,10 @@
import React from 'react'

export default props => {
return (
<div>
<span>{props.message}</span>
<button onClick={props.reset} />
</div>
)
}
2 changes: 2 additions & 0 deletions tests/utils/isReactComponent-test.js
@@ -1,6 +1,7 @@
import isReactComponent from '../../src/utils/isReactComponent'
import ReactComponent from '../fixtures/ReactComponent'
import ReactPureFunctionalComponent from '../fixtures/ReactPureFunctionalComponent'
import ReactFunctionalComponent from '../fixtures/ReactFunctionalComponent'
import VueComponent from '../fixtures/VueComponent'
import VueRegisteredComponent from '../fixtures/VueRegisteredComponent'
import VueSingleFileComponent from '../fixtures/VueSingleFileComponent.vue'
Expand All @@ -9,6 +10,7 @@ describe('isReactComponent', () => {
it('returns true for React components', () => {
expect(isReactComponent(ReactComponent)).toBe(true)
expect(isReactComponent(ReactPureFunctionalComponent)).toBe(true)
expect(isReactComponent(ReactFunctionalComponent)).toBe(true)
})

it('returns false for Vue components', () => {
Expand Down

0 comments on commit 22567e7

Please sign in to comment.