react-context-toolbox
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -0,1 +1,9 @@ | ||
<a name="1.2.3"></a> | ||
## [1.2.3](https://github.com/4Catalyzer/react-context-toolbox/compare/v1.2.2...v1.2.3) (2018-10-30) | ||
### Bug Fixes | ||
* avoid rendering Context directly warning ([fb0262a](https://github.com/4Catalyzer/react-context-toolbox/commit/fb0262a)) | ||
<a name="1.2.2"></a> | ||
@@ -2,0 +10,0 @@ ## [1.2.2](https://github.com/4Catalyzer/react-context-toolbox/compare/v1.2.1...v1.2.2) (2018-09-09) |
@@ -19,2 +19,6 @@ "use strict"; | ||
var ensureConsumer = function ensureConsumer(c) { | ||
return c.Consumer || c; | ||
}; | ||
function $mapContextToProps(_ref, Component) { | ||
@@ -32,3 +36,3 @@ var maybeArrayOfConsumers = _ref.consumers, | ||
var SingleConsumer = consumers[0]; | ||
var SingleConsumer = ensureConsumer(consumers[0]); | ||
@@ -50,3 +54,3 @@ function singleRender(props, ref) { | ||
return consumers.reduceRight(function (inner, Consumer) { | ||
return consumers.reduceRight(function (inner, Context) { | ||
return function () { | ||
@@ -57,2 +61,3 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
var Consumer = ensureConsumer(Context); | ||
return _react.default.createElement(Consumer, null, function (value) { | ||
@@ -59,0 +64,0 @@ return inner.apply(void 0, args.concat([value])); |
{ | ||
"name": "react-context-toolbox", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"main": "lib/index.js", | ||
@@ -62,3 +62,2 @@ "modules": "es/index.js", | ||
"@babel/core": "^7.0.0-beta.39", | ||
"@monastic.panic/enzyme-adapter-react-16": "^1.2.2", | ||
"babel-core": "bridge", | ||
@@ -68,3 +67,4 @@ "babel-eslint": "^8.2.1", | ||
"codecov": "^3.0.2", | ||
"enzyme": "^3.3.0", | ||
"enzyme": "^3.7.0", | ||
"enzyme-adapter-react-16": "^1.6.0", | ||
"eslint": "^4.16.0", | ||
@@ -82,4 +82,4 @@ "eslint-config-4catalyzer-react": "^0.4.1", | ||
"prettier": "^1.10.2", | ||
"react": "^16.3.2", | ||
"react-dom": "^16.3.2", | ||
"react": "^16.6.0", | ||
"react-dom": "^16.6.0", | ||
"semantic-release": "^15.4.0", | ||
@@ -86,0 +86,0 @@ "travis-deploy-once": "^5.0.0" |
@@ -12,2 +12,4 @@ import React from 'react'; | ||
const ensureConsumer = c => c.Consumer || c; | ||
function $mapContextToProps( | ||
@@ -27,3 +29,3 @@ { | ||
const SingleConsumer = consumers[0]; | ||
const SingleConsumer = ensureConsumer(consumers[0]); | ||
function singleRender(props, ref) { | ||
@@ -43,5 +45,6 @@ const propsWithRef = { [forwardRefAs]: ref, ...props }; | ||
return consumers.reduceRight( | ||
(inner, Consumer) => (...args) => ( | ||
<Consumer>{value => inner(...args, value)}</Consumer> | ||
), | ||
(inner, Context) => (...args) => { | ||
const Consumer = ensureConsumer(Context); | ||
return <Consumer>{value => inner(...args, value)}</Consumer>; | ||
}, | ||
(...contexts) => ( | ||
@@ -48,0 +51,0 @@ <Component {...propsWithRef} {...mapToProps(...contexts, props)} /> |
import { configure } from 'enzyme'; | ||
import Adapter from '@monastic.panic/enzyme-adapter-react-16'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
configure({ adapter: new Adapter() }); |
@@ -140,2 +140,14 @@ import React from 'react'; | ||
}); | ||
it('should not warn about Contexts', () => { | ||
const Mapper = mapContextToProps( | ||
{ | ||
consumers: React.createContext('foo'), | ||
mapToProps: foo => ({ children: foo }), | ||
displayName: 'WithIntl', | ||
}, | ||
'div', | ||
); | ||
mount(<Mapper />); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
349888
417