UNPKG

1.76 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = exports.configureWithClientMainQuery = void 0;
9
10var _reactRedux = require("react-redux");
11
12var _lifecycle = _interopRequireDefault(require("recompose/lifecycle"));
13
14var _compose = _interopRequireDefault(require("recompose/compose"));
15
16/* eslint-disable import/no-extraneous-dependencies */
17// flow-disable-next-line
18var configuredFetchPageThunk;
19
20var configureWithClientMainQuery = function configureWithClientMainQuery(fetchPageThunk) {
21 configuredFetchPageThunk = fetchPageThunk;
22};
23
24exports.configureWithClientMainQuery = configureWithClientMainQuery;
25var lifecycle = {
26 componentDidMount: function componentDidMount() {
27 if (!configuredFetchPageThunk) {
28 throw Error('You must configure a fetchPageThunk with configureWithClientMainQuery');
29 }
30
31 var _this$props = this.props,
32 dispatch = _this$props.dispatch,
33 route = _this$props.route;
34
35 if (route.mainQuery) {
36 var urlParams = this.props.match.params;
37 var _route$mainQuery = route.mainQuery,
38 query = _route$mainQuery.query,
39 mapUrlParams = _route$mainQuery.mapUrlParams,
40 mapResp = _route$mainQuery.mapResp;
41 dispatch(configuredFetchPageThunk({
42 query: query,
43 urlParams: urlParams,
44 mapUrlParams: mapUrlParams,
45 mapResp: mapResp
46 }));
47 }
48 }
49};
50
51var withClientMainQuery = function withClientMainQuery() {
52 return (0, _compose.default)((0, _reactRedux.connect)(function () {
53 return {};
54 }), (0, _lifecycle.default)(lifecycle));
55};
56
57var _default = withClientMainQuery;
58exports.default = _default;
\No newline at end of file