Repository URL to install this package:
|
Version:
2.7.11 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const prop_types_1 = tslib_1.__importDefault(require("prop-types"));
const mobx_react_1 = require("xmobx/mobx-react");
const state_1 = require("../../../state");
const renderProps_1 = require("./renderProps");
let Blink = class Blink extends react_1.default.Component {
constructor() {
super(...arguments);
this.observableState = state_1.toCommonState(this.props);
}
componentDidMount() {
this.blink();
}
componentWillUnmount() {
clearInterval(this.timeout);
}
/**
* @todo this should really be an action on the state?
*/
blink() {
this.timeout = setInterval(this.observableState.toggleVisibility, this.props.duration);
}
render() {
const _a = this.props,
{
renderChildren,
renderWrapper
} = _a,
remainingProps = tslib_1.__rest(_a, ["renderChildren", "renderWrapper"]);
const children = renderChildren(remainingProps);
return renderWrapper(Object.assign({
children
}, remainingProps), this.observableState);
}
};
Blink.defaultProps = {
className: '',
duration: 530,
renderChildren: renderProps_1.defaultRenderChildren,
renderWrapper: renderProps_1.defaultRenderWrapper
};
Blink.propTypes = {
className: prop_types_1.default.string,
duration: prop_types_1.default.number,
children: prop_types_1.default.node,
state: prop_types_1.default.object,
renderChildren: prop_types_1.default.func,
renderWrapper: prop_types_1.default.func
};
Blink = tslib_1.__decorate([mobx_react_1.observer], Blink);
exports.Blink = Blink;
exports.default = Blink; //# sourceMappingURL=Blink.js.map