@quintype/framework 7.3.2-term-connection-on-config.0 → 7.4.0-react-18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [7.3.2](https://github.com/quintype/quintype-node-framework/compare/v7.3.1...v7.3.2) (2022-04-18)
6
+
5
7
  ### [7.3.1](https://github.com/quintype/quintype-node-framework/compare/v7.3.0...v7.3.1) (2022-03-03)
6
8
 
7
9
  ## [7.3.0](https://github.com/quintype/quintype-node-framework/compare/v7.2.0...v7.3.0) (2022-03-01)
package/client/start.js CHANGED
@@ -11,7 +11,7 @@ import { BreakingNews, CLIENT_SIDE_RENDERED, NAVIGATE_TO_PAGE, PAGE_LOADING } fr
11
11
  import { createBrowserHistory } from "history";
12
12
  import get from "lodash/get";
13
13
  import React from "react";
14
- import ReactDOM from "react-dom";
14
+ import { createRoot, hydrateRoot } from "react-dom/client";
15
15
  import { Provider } from "react-redux";
16
16
  import { IsomorphicComponent } from "../isomorphic/component";
17
17
  import { makePickComponentSync } from "../isomorphic/impl/make-pick-component-sync";
@@ -181,10 +181,21 @@ export function maybeSetUrl(path, title) {
181
181
  export function renderComponent(clazz, container, store, props = {}, callback) {
182
182
  const component = React.createElement(Provider, { store }, React.createElement(clazz, props || {}));
183
183
 
184
+ function AppWithCallbackAfterRender() {
185
+ useEffect(() => {
186
+ callback();
187
+ });
188
+
189
+ return component;
190
+ }
191
+
192
+ let root = createRoot(document.getElementById(container));
193
+
184
194
  if (props.hydrate) {
185
- return ReactDOM.hydrate(component, document.getElementById(container), callback);
195
+ root = hydrateRoot(document.getElementById(container));
186
196
  }
187
- return ReactDOM.render(component, document.getElementById(container), callback);
197
+
198
+ return root.render(<AppWithCallbackAfterRender />);
188
199
  }
189
200
 
190
201
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.3.2-term-connection-on-config.0",
3
+ "version": "7.4.0-react-18.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -47,8 +47,8 @@
47
47
  "mocha-snapshots": "^4.2.0",
48
48
  "morgan": "^1.10.0",
49
49
  "path-to-regexp": "^6.2.0",
50
- "react": "^16.14.0",
51
- "react-dom": "^16.14.0",
50
+ "react": "^18.0.0",
51
+ "react-dom": "^18.0.0",
52
52
  "react-redux": "^7.2.5",
53
53
  "react-router": "^5.2.1",
54
54
  "redux": "^4.1.1",
package/server/routes.js CHANGED
@@ -168,10 +168,7 @@ function withConfigPartial(
168
168
  })
169
169
  )
170
170
  )
171
- .catch((e) => {
172
- logError(e);
173
- res.status(500).send("An internal error occured for this publisher's config");
174
- });
171
+ .catch(logError);
175
172
  };
176
173
  };
177
174
  }
@@ -25,7 +25,6 @@ const cdnProviderFunc = () => "akamai";
25
25
 
26
26
  function createApp(loadData, routes, opts = {}, app = express()) {
27
27
  const { redirectToLowercaseSlugs = false } = opts;
28
- const emptyFunc = () => {};
29
28
  isomorphicRoutes(
30
29
  app,
31
30
  Object.assign(
@@ -34,10 +33,9 @@ function createApp(loadData, routes, opts = {}, app = express()) {
34
33
  assetHash: (file) => (file === "app.js" ? "abcdef" : null),
35
34
  assetPath: (file) => `/assets/${file}`,
36
35
  },
37
- getClient: opts.getClientStub || getClientStub,
36
+ getClient: getClientStub,
38
37
  generateRoutes: () => routes,
39
38
  loadData,
40
- logError: opts.logError || emptyFunc,
41
39
  pickComponent: opts.pickComponent || pickComponent,
42
40
  renderLayout: (res, { store, title, content }) =>
43
41
  res.send(JSON.stringify({ store: store.getState(), title, content })),
@@ -53,33 +51,6 @@ function createApp(loadData, routes, opts = {}, app = express()) {
53
51
  }
54
52
 
55
53
  describe("Isomorphic Handler", function () {
56
- it("Renders a 404 when a publisher is not found", function (done) {
57
- const app = createApp(
58
- (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
59
- [{ pageType: "home-page", path: "/", exact: true }],
60
- {
61
- getClientStub: (hostname) => {
62
- return {
63
- getHostname: () => "demo.quintype.io",
64
- getConfig: () => Promise.reject("Pubisher not found"),
65
- baseUrl: "https://www.foo.com",
66
- };
67
- },
68
- logError: (error) => {
69
- console.log(error);
70
- },
71
- }
72
- );
73
-
74
- supertest(app)
75
- .get("/")
76
- .expect(500)
77
- .then((res) => {
78
- assert.equal("An internal error occured for this publisher's config", res.text);
79
- })
80
- .then(done);
81
- });
82
-
83
54
  it("Renders the page if the route matches", function (done) {
84
55
  const app = createApp(
85
56
  (pageType, params, config, client, { host }) =>