UNPKG

react-facebook-next

Version:

Facebook components like a Login button, Like, Share, Comments or Embedded Post

73 lines (59 loc) 2.1 kB
import _regeneratorRuntime from 'babel-runtime/regenerator'; import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; var _class, _temp; import { Component } from 'react'; import PropTypes from 'prop-types'; import canUseDOM from 'can-use-dom'; var InitFacebook = (_temp = _class = function (_Component) { _inherits(InitFacebook, _Component); function InitFacebook() { _classCallCheck(this, InitFacebook); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } InitFacebook.prototype.componentDidMount = function componentDidMount() { if (canUseDOM) { this.initFacebook(); } }; InitFacebook.prototype.initFacebook = function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var onReady, facebook; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: onReady = this.props.onReady; _context.next = 3; return this.context.facebook.init(); case 3: facebook = _context.sent; onReady(facebook); case 5: case 'end': return _context.stop(); } } }, _callee, this); })); function initFacebook() { return _ref.apply(this, arguments); } return initFacebook; }(); InitFacebook.prototype.render = function render() { return this.props.children; }; return InitFacebook; }(Component), _class.propTypes = { children: PropTypes.node, onReady: PropTypes.func.isRequired }, _class.defaultProps = { children: undefined }, _class.contextTypes = { facebook: PropTypes.object.isRequired }, _temp); export { InitFacebook as default }; //# sourceMappingURL=InitFacebook.js.map