Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395038 )

Change subject: Chore: use function keyword in client and server
......................................................................

Chore: use function keyword in client and server

Use the function keyword instead of the arrow operator for top level
functions in the client and server. Additionally, TypeScript required
that the client's `pageRoot` be defined at declaration time due to
hoisting.

Change-Id: I96f07c6488d170c5d85769fb6df5e3c84135c4e8
---
M src/client/index.tsx
M src/server/index.tsx
2 files changed, 12 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/38/395038/1

diff --git a/src/client/index.tsx b/src/client/index.tsx
index 8ddff0e..0386958 100644
--- a/src/client/index.tsx
+++ b/src/client/index.tsx
@@ -15,13 +15,15 @@
 
 const history = newHistory();
 const router = newRouter(routes);
-const pageRoot = document.getElementById("root");
-if (!pageRoot) {
+const pageRoot = (_ => {
+  const root = document.getElementById("root");
+  if (root) return root;
+
   // A "root" container for the app should be present in the Page component.
   throw new Error('Missing element with "root" ID.');
-}
+})();
 
-const renderPageRoot = ({ Component, props }: RouteResponse<any>) => {
+function renderPageRoot({ Component, props }: RouteResponse<any>) {
   render(
     <WithContext history={history}>
       <Component {...props} />
@@ -29,9 +31,11 @@
     pageRoot,
     pageRoot.lastElementChild || undefined
   );
-};
+}
 
-const route = (path: string) => router.route(path).then(renderPageRoot);
+function route(path: string) {
+  router.route(path).then(renderPageRoot);
+}
 
 // Observe the History
 history.listen(location => route(location.pathname));
diff --git a/src/server/index.tsx b/src/server/index.tsx
index 118b9fa..fb30274 100644
--- a/src/server/index.tsx
+++ b/src/server/index.tsx
@@ -14,7 +14,7 @@
 
 server.use("/public", express.static("dist/public"));
 
-const render = ({ chunkName, Component, props }: RouteResponse<any>) => {
+function render({ chunkName, Component, props }: RouteResponse<any>) {
   return (
     "<!doctype html>" + // eslint-disable-line prefer-template
     renderToString(
@@ -23,7 +23,7 @@
       </HTMLPage>
     )
   );
-};
+}
 
 const router = newRouter(routes);
 server.get("*", (request, response) => {

-- 
To view, visit https://gerrit.wikimedia.org/r/395038
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I96f07c6488d170c5d85769fb6df5e3c84135c4e8
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to