UNPKG

react-facebook-next

Version:

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

108 lines (89 loc) 3.26 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 FB from './Facebook'; var facebookInstance = null; var Facebook = (_temp = _class = function (_Component) { _inherits(Facebook, _Component); function Facebook() { _classCallCheck(this, Facebook); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } Facebook.prototype.getChildContext = function getChildContext() { return { facebook: this }; }; Facebook.prototype.init = function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var _props, domain, version, appId, cookie, status, xfbml, language, frictionlessRequests, wait; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: if (!this.facebook) { _props = this.props, domain = _props.domain, version = _props.version, appId = _props.appId, cookie = _props.cookie, status = _props.status, xfbml = _props.xfbml, language = _props.language, frictionlessRequests = _props.frictionlessRequests, wait = _props.wait; this.facebook = facebookInstance || new FB({ domain: domain, appId: appId, version: version, cookie: cookie, status: status, xfbml: xfbml, language: language, frictionlessRequests: frictionlessRequests, wait: wait }); facebookInstance = this.facebook; } _context.next = 3; return this.facebook.init(); case 3: return _context.abrupt('return', this.facebook); case 4: case 'end': return _context.stop(); } } }, _callee, this); })); function init() { return _ref.apply(this, arguments); } return init; }(); Facebook.prototype.render = function render() { return this.props.children; }; return Facebook; }(Component), _class.propTypes = { appId: PropTypes.string.isRequired, domain: PropTypes.string, version: PropTypes.string, cookie: PropTypes.bool, status: PropTypes.bool, xfbml: PropTypes.bool, language: PropTypes.string, frictionlessRequests: PropTypes.bool, children: PropTypes.node, wait: PropTypes.bool }, _class.childContextTypes = { facebook: PropTypes.object.isRequired }, _class.defaultProps = { version: 'v2.9', cookie: false, status: false, xfbml: false, language: 'en_US', frictionlessRequests: false, domain: 'connect.facebook.net', children: undefined, wait: false }, _temp); export { Facebook as default }; //# sourceMappingURL=FacebookProvider.js.map