json-react-layouts-data-loader
Advanced tools
Comparing version 4.0.0-beta.5 to 4.0.0-beta.6
# json-react-layouts-data-loader | ||
## 4.0.0-beta.6 | ||
### Minor Changes | ||
- 9a6621d: Upgraded dependencies | ||
### Patch Changes | ||
- Updated dependencies [9a6621d] | ||
- json-react-layouts@3.0.0-beta.6 | ||
## 4.0.0-beta.5 | ||
@@ -4,0 +15,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getComponentDataArgs = void 0; | ||
function getComponentDataArgs(layout, componentType) { | ||
@@ -4,0 +5,0 @@ var componentDataDefinition = layout.componentRegistrations.get(componentType); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getComponentDataArgs = exports.init = void 0; | ||
var tslib_1 = require("tslib"); | ||
var react_1 = tslib_1.__importDefault(require("react")); | ||
var get_data_args_1 = require("./get-data-args"); | ||
exports.getComponentDataArgs = get_data_args_1.getComponentDataArgs; | ||
Object.defineProperty(exports, "getComponentDataArgs", { enumerable: true, get: function () { return get_data_args_1.getComponentDataArgs; } }); | ||
// TODO this could have a better name | ||
@@ -11,3 +11,3 @@ function init(resources, | ||
wrapLoad) { | ||
var ComponentDataLoader = resources.registerResource('component-data-loader', function (_a) { | ||
var useComponentData = resources.registerResource('component-data-loader', function (_a) { | ||
var dataDefinitionArgs = _a.dataDefinitionArgs, dataDefinition = _a.dataDefinition, layout = _a.layout, resourceType = _a.resourceType, paramsCacheKey = _a.paramsCacheKey, services = tslib_1.__rest(_a, ["dataDefinitionArgs", "dataDefinition", "layout", "resourceType", "paramsCacheKey"]); | ||
@@ -46,13 +46,17 @@ var loadFn = wrapLoad ? wrapLoad(dataDefinition.loadData) : dataDefinition.loadData; | ||
} | ||
return (react_1.default.createElement(ComponentDataLoader, { layout: services.layout, dataDefinition: dataDefinition, dataDefinitionArgs: dataDefinitionArgs, renderData: function (renderProps) { | ||
if (!renderProps.lastAction.success) { | ||
// We have failed to load data, use error boundaries | ||
// to send error back up and render error page | ||
throw renderProps.lastAction.error; | ||
} | ||
var data = renderProps.data.hasData | ||
? { data: { loaded: true, result: renderProps.data.result } } | ||
: { data: { loaded: false } }; | ||
return (next(tslib_1.__assign(tslib_1.__assign({}, componentProps), data), middlewareProps, services) || null); | ||
} })); | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
var renderProps = useComponentData({ | ||
dataDefinition: dataDefinition, | ||
dataDefinitionArgs: dataDefinitionArgs, | ||
layout: services.layout, | ||
}); | ||
if (!renderProps.lastAction.success) { | ||
// We have failed to load data, use error boundaries | ||
// to send error back up and render error page | ||
throw renderProps.lastAction.error; | ||
} | ||
var data = renderProps.data.hasData | ||
? { data: { loaded: true, result: renderProps.data.result } } | ||
: { data: { loaded: false } }; | ||
return (next(tslib_1.__assign(tslib_1.__assign({}, componentProps), data), middlewareProps, services) || null); | ||
} | ||
@@ -59,0 +63,0 @@ return next(componentProps, middlewareProps, services); |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=DataLoading.js.map |
import { __assign, __rest } from "tslib"; | ||
import React from 'react'; | ||
import { getComponentDataArgs } from './get-data-args'; | ||
@@ -8,3 +7,3 @@ // TODO this could have a better name | ||
wrapLoad) { | ||
var ComponentDataLoader = resources.registerResource('component-data-loader', function (_a) { | ||
var useComponentData = resources.registerResource('component-data-loader', function (_a) { | ||
var dataDefinitionArgs = _a.dataDefinitionArgs, dataDefinition = _a.dataDefinition, layout = _a.layout, resourceType = _a.resourceType, paramsCacheKey = _a.paramsCacheKey, services = __rest(_a, ["dataDefinitionArgs", "dataDefinition", "layout", "resourceType", "paramsCacheKey"]); | ||
@@ -43,13 +42,17 @@ var loadFn = wrapLoad ? wrapLoad(dataDefinition.loadData) : dataDefinition.loadData; | ||
} | ||
return (React.createElement(ComponentDataLoader, { layout: services.layout, dataDefinition: dataDefinition, dataDefinitionArgs: dataDefinitionArgs, renderData: function (renderProps) { | ||
if (!renderProps.lastAction.success) { | ||
// We have failed to load data, use error boundaries | ||
// to send error back up and render error page | ||
throw renderProps.lastAction.error; | ||
} | ||
var data = renderProps.data.hasData | ||
? { data: { loaded: true, result: renderProps.data.result } } | ||
: { data: { loaded: false } }; | ||
return (next(__assign(__assign({}, componentProps), data), middlewareProps, services) || null); | ||
} })); | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
var renderProps = useComponentData({ | ||
dataDefinition: dataDefinition, | ||
dataDefinitionArgs: dataDefinitionArgs, | ||
layout: services.layout, | ||
}); | ||
if (!renderProps.lastAction.success) { | ||
// We have failed to load data, use error boundaries | ||
// to send error back up and render error page | ||
throw renderProps.lastAction.error; | ||
} | ||
var data = renderProps.data.hasData | ||
? { data: { loaded: true, result: renderProps.data.result } } | ||
: { data: { loaded: false } }; | ||
return (next(__assign(__assign({}, componentProps), data), middlewareProps, services) || null); | ||
} | ||
@@ -56,0 +59,0 @@ return next(componentProps, middlewareProps, services); |
{ | ||
"name": "json-react-layouts-data-loader", | ||
"version": "4.0.0-beta.5", | ||
"version": "4.0.0-beta.6", | ||
"repository": "github:sevenwestmedia-labs/json-react-layouts", | ||
@@ -11,8 +11,8 @@ "author": "Seven West Media WA", | ||
"dependencies": { | ||
"json-react-layouts": "^3.0.0-beta.5" | ||
"json-react-layouts": "^3.0.0-beta.6" | ||
}, | ||
"peerDependencies": { | ||
"typescript-log": "^1.1.1", | ||
"react-ssr-data-loader": "^1.3.0" | ||
"typescript-log": "^2.0.0", | ||
"react-ssr-data-loader": "^2.0.0-next.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1087
244891
+ Addedis-promise@4.0.0(transitive)
+ Addedreact-ssr-data-loader@2.0.0-next.4(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtypescript-log@2.0.0(transitive)
+ Addeduse-force-update@1.0.11(transitive)
- Removedis-promise@2.2.2(transitive)
- Removedreact-ssr-data-loader@1.3.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedtypescript-log@1.1.1(transitive)