Skip to content

Commit

Permalink
fix(react-context): add react import (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Idered authored Apr 19, 2018
1 parent bf870b4 commit 28a27a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/react-context/index.es5.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SyncanoContext = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.withSyncano = withSyncano;
var SyncanoContext = exports.SyncanoContext = React.createContext();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const SyncanoContext = exports.SyncanoContext = _react2.default.createContext();

// This function takes a component...
function withSyncano(Component) {
// ...and returns another component...
return function SyncanoComponent(props) {
// ... and renders the wrapped component with the context theme!
// Notice that we pass through any additional props as well
return React.createElement(
return _react2.default.createElement(
SyncanoContext.Consumer,
null,
function (syncano) {
return React.createElement(Component, _extends({}, props, { syncano: syncano }));
}
syncano => _react2.default.createElement(Component, _extends({}, props, { syncano: syncano }))
);
};
}
2 changes: 2 additions & 0 deletions packages/react-context/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react'

export const SyncanoContext = React.createContext()

// This function takes a component...
Expand Down

0 comments on commit 28a27a7

Please sign in to comment.