graphql-react
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
# graphql-react changelog | ||
## 1.0.0-alpha.3 | ||
* Support the legacy React context API, fixing [#7](https://github.com/jaydenseric/graphql-react/issues/7). | ||
* Use [`eslint-plugin-ava`](https://npm.im/eslint-plugin-ava). | ||
## 1.0.0-alpha.2 | ||
@@ -4,0 +9,0 @@ |
@@ -13,3 +13,11 @@ 'use strict' | ||
function preload(element) { | ||
var recursePreload = function recursePreload(rootElement, loadRoot) { | ||
var recursePreload = function recursePreload( | ||
rootElement, | ||
rootLegacyContext, | ||
loadRoot | ||
) { | ||
if (rootLegacyContext === void 0) { | ||
rootLegacyContext = {} | ||
} | ||
if (loadRoot === void 0) { | ||
@@ -21,3 +29,3 @@ loadRoot = true | ||
var recurse = function recurse(element) { | ||
var recurse = function recurse(element, legacyContext) { | ||
if (!element) return | ||
@@ -27,3 +35,3 @@ | ||
element.forEach(function(item) { | ||
return recurse(item) | ||
return recurse(item, legacyContext) | ||
}) | ||
@@ -43,3 +51,6 @@ return | ||
if (element.type.Consumer) | ||
recurse(element.props.children(element.type.currentValue)) | ||
recurse( | ||
element.props.children(element.type.currentValue), | ||
legacyContext | ||
) | ||
else if ( | ||
@@ -50,3 +61,3 @@ element.type.prototype && | ||
) { | ||
var instance = new element.type(props) | ||
var instance = new element.type(props, legacyContext) | ||
instance.state = instance.state || null | ||
@@ -65,2 +76,8 @@ | ||
if (instance.componentWillMount) instance.componentWillMount() | ||
if (instance.getChildContext) | ||
legacyContext = (0, _objectAssign.default)( | ||
{}, | ||
legacyContext, | ||
instance.getChildContext() | ||
) | ||
if ( | ||
@@ -73,15 +90,15 @@ instance.constructor.name === 'GraphQLQuery' && | ||
instance.load().then(function() { | ||
return recursePreload(element, false) | ||
return recursePreload(element, legacyContext, false) | ||
}) | ||
) | ||
else recurse(instance.render()) | ||
} else recurse(element.type(props)) | ||
else recurse(instance.render(), legacyContext) | ||
} else recurse(element.type(props), legacyContext) | ||
} else if (element.props && element.props.children) { | ||
if (element.type.context) | ||
element.type.context.currentValue = element.props.value | ||
recurse(element.props.children) | ||
recurse(element.props.children, legacyContext) | ||
} | ||
} | ||
recurse(rootElement) | ||
recurse(rootElement, rootLegacyContext) | ||
return Promise.all(loading) | ||
@@ -88,0 +105,0 @@ } |
{ | ||
"name": "graphql-react", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"description": "A lightweight GraphQL client for React.", | ||
@@ -59,2 +59,3 @@ "license": "MIT", | ||
"eslint": "^4.19.0", | ||
"eslint-plugin-ava": "^4.5.1", | ||
"eslint-plugin-prettier": "^2.5.0", | ||
@@ -119,4 +120,8 @@ "eslint-plugin-react": "^7.7.0", | ||
}, | ||
"extends": ["eslint:recommended", "plugin:react/recommended"], | ||
"plugins": ["react", "prettier"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:ava/recommended" | ||
], | ||
"plugins": ["react", "ava", "prettier"], | ||
"rules": { | ||
@@ -123,0 +128,0 @@ "require-jsdoc": "warn", |
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
51627
828
32