react-on-rails
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0-rc.1
@@ -56,3 +56,3 @@ 'use strict'; | ||
*/ | ||
getComponent: function getComponent(name) { | ||
get: function get(name) { | ||
var ctx = (0, _context2.default)(); | ||
@@ -73,4 +73,5 @@ if (_components.has(name)) { | ||
/** | ||
* Get an Object containing all registered components. Useful for debugging. | ||
* @returns {*} | ||
* Get an Map containing all registered components. Useful for debugging. | ||
* @returns Map where key is the component name and values are the | ||
* { name, component, generatorFunction} | ||
*/ | ||
@@ -77,0 +78,0 @@ components: function components() { |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -7,37 +7,18 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.default = generatorFunction; | ||
// See discussion: https://discuss.reactjs.org/t/how-to-determine-if-js-object-is-react-component/2825/2 | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function allObjectKeys(obj) { | ||
var result = []; | ||
/* eslint-disable guard-for-in */ | ||
for (var prop in obj) { | ||
result.push(prop); | ||
} | ||
return result; | ||
} | ||
function arrIncludes(arr, value) { | ||
return arr.indexOf(value) > -1; | ||
} | ||
/** | ||
* Used to determine we'll call be calling React.createElement on the component of if this is a | ||
* generator function used return a function that takes props to return a React element | ||
* @param component | ||
* @returns {boolean} | ||
*/ | ||
function generatorFunction(component) { | ||
var prototypeKeys = allObjectKeys(component.prototype); | ||
var keys = allObjectKeys(component); | ||
// es5 React Component | ||
if (arrIncludes(prototypeKeys, 'constructor') && arrIncludes(prototypeKeys, 'render')) { | ||
if (!component.prototype) { | ||
return false; | ||
} else if (arrIncludes(prototypeKeys, 'isReactComponent') // es6 React Component | ||
|| arrIncludes(keys, 'propTypes') || component.prototype instanceof _react2.default.Component) { | ||
return false; | ||
} | ||
// Else, we assume a generator function! | ||
return true; | ||
// es5 or es6 React Component | ||
var es5OrEs6ReactComponent = component.prototype.isReactComponent; | ||
return !es5OrEs6ReactComponent; | ||
} |
@@ -75,3 +75,3 @@ 'use strict'; | ||
getComponent: function getComponent(name) { | ||
return _ComponentStore2.default.getComponent(name); | ||
return _ComponentStore2.default.get(name); | ||
}, | ||
@@ -78,0 +78,0 @@ |
{ | ||
"name": "react-on-rails", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-rc.1", | ||
"description": "react-on-rails JavaScript for react_on_rails Ruby gem", | ||
@@ -5,0 +5,0 @@ "main": "node_package/lib/ReactOnRails.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46891
449