@rxx/core
Version:
React MVI micro framework.
54 lines • 3.05 kB
JavaScript
;
/**
* The MIT License (MIT)
* Copyright (c) Taketoshi Aono
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* @fileoverview
* @author Taketoshi Aono
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var connect_1 = require("./connect");
/**
* Stateless component utils.
* @example
* const Component = view((props, context) => {
* return <div></div>;
* })
*/
function view(renderer, displayName) {
var _a;
return _a = /** @class */ (function (_super) {
tslib_1.__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.render = function () {
return renderer(this.props, this.context);
};
Object.defineProperty(class_1, "displayName", {
get: function () {
return displayName || 'StatelessView';
},
enumerable: true,
configurable: true
});
return class_1;
}(React.Component)),
_a.contextTypes = connect_1.CONTEXT_TYPES,
_a;
}
exports.view = view;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmlldy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9kZWNvcmF0b3JzL3ZpZXcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7OztHQWlCRzs7O0FBRUgsbURBQStCO0FBQy9CLHFDQUEwQztBQUUxQzs7Ozs7O0dBTUc7QUFDSCxTQUFnQixJQUFJLENBQ2xCLFFBQTJELEVBQzNELFdBQW9COztJQUVwQjtZQUFxQixtQ0FBeUI7WUFBdkM7O1lBV1AsQ0FBQztZQVBRLHdCQUFNLEdBQWI7Z0JBQ0UsT0FBTyxRQUFRLENBQUMsSUFBSSxDQUFDLEtBQVksRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7WUFDbkQsQ0FBQztZQUVELHNCQUFrQixzQkFBVztxQkFBN0I7b0JBQ0UsT0FBTyxXQUFXLElBQUksZUFBZSxDQUFDO2dCQUN4QyxDQUFDOzs7ZUFBQTtZQUNILGNBQUM7UUFBRCxDQUFDLEFBWE0sQ0FBYyxLQUFLLENBQUMsU0FBUztRQUNwQixlQUFZLEdBQUcsdUJBQWM7V0FVM0M7QUFDSixDQUFDO0FBaEJELG9CQWdCQyJ9