-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-context): add react import (#221)
- Loading branch information
Showing
2 changed files
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 })) | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters