1
0

3 Commits 0d9f15838f ... 5a227fb72c

Autor SHA1 Nachricht Datum
  mightyplow 5a227fb72c extract AppContextProvider vor 5 Jahren
  mightyplow 172d97e35b disable import ordering vor 5 Jahren
  mightyplow a2aaf4f5ba update packages vor 5 Jahren
5 geänderte Dateien mit 92 neuen und 53 gelöschten Zeilen
  1. 56 29
      package-lock.json
  2. 3 22
      src/layout/App.tsx
  3. 1 1
      src/layout/AppContext.ts
  4. 31 0
      src/layout/AppContextProvider.tsx
  5. 1 1
      tslint.json

+ 56 - 29
package-lock.json

@@ -3020,6 +3020,13 @@
       "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==",
       "dev": true
     },
+    "file-uri-to-path": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
+      "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
+      "dev": true,
+      "optional": true
+    },
     "filesize": {
       "version": "3.6.1",
       "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
@@ -3109,14 +3116,15 @@
       "dev": true
     },
     "fsevents": {
-      "version": "1.2.9",
-      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz",
-      "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==",
+      "version": "1.2.11",
+      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.11.tgz",
+      "integrity": "sha512-+ux3lx6peh0BpvY0JebGyZoiR4D+oYzdPZMKJwkZ+sFkNJzpL7tXc/wehS49gUAxg3tmMHPHZkA8JU2rhhgDHw==",
       "dev": true,
       "optional": true,
       "requires": {
+        "bindings": "^1.5.0",
         "nan": "^2.12.1",
-        "node-pre-gyp": "^0.12.0"
+        "node-pre-gyp": "*"
       },
       "dependencies": {
         "abbrev": {
@@ -3153,6 +3161,16 @@
           "dev": true,
           "optional": true
         },
+        "bindings": {
+          "version": "1.5.0",
+          "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
+          "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "file-uri-to-path": "1.0.0"
+          }
+        },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
@@ -3164,7 +3182,7 @@
           }
         },
         "chownr": {
-          "version": "1.1.1",
+          "version": "1.1.3",
           "bundled": true,
           "dev": true,
           "optional": true
@@ -3194,7 +3212,7 @@
           "optional": true
         },
         "debug": {
-          "version": "4.1.1",
+          "version": "3.2.6",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3221,12 +3239,12 @@
           "optional": true
         },
         "fs-minipass": {
-          "version": "1.2.5",
+          "version": "1.2.7",
           "bundled": true,
           "dev": true,
           "optional": true,
           "requires": {
-            "minipass": "^2.2.1"
+            "minipass": "^2.6.0"
           }
         },
         "fs.realpath": {
@@ -3252,7 +3270,7 @@
           }
         },
         "glob": {
-          "version": "7.1.3",
+          "version": "7.1.6",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3281,7 +3299,7 @@
           }
         },
         "ignore-walk": {
-          "version": "3.0.1",
+          "version": "3.0.3",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3300,7 +3318,7 @@
           }
         },
         "inherits": {
-          "version": "2.0.3",
+          "version": "2.0.4",
           "bundled": true,
           "dev": true,
           "optional": true
@@ -3342,7 +3360,7 @@
           "optional": true
         },
         "minipass": {
-          "version": "2.3.5",
+          "version": "2.9.0",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3352,12 +3370,12 @@
           }
         },
         "minizlib": {
-          "version": "1.2.1",
+          "version": "1.3.3",
           "bundled": true,
           "dev": true,
           "optional": true,
           "requires": {
-            "minipass": "^2.2.1"
+            "minipass": "^2.9.0"
           }
         },
         "mkdirp": {
@@ -3370,24 +3388,24 @@
           }
         },
         "ms": {
-          "version": "2.1.1",
+          "version": "2.1.2",
           "bundled": true,
           "dev": true,
           "optional": true
         },
         "needle": {
-          "version": "2.3.0",
+          "version": "2.4.0",
           "bundled": true,
           "dev": true,
           "optional": true,
           "requires": {
-            "debug": "^4.1.0",
+            "debug": "^3.2.6",
             "iconv-lite": "^0.4.4",
             "sax": "^1.2.4"
           }
         },
         "node-pre-gyp": {
-          "version": "0.12.0",
+          "version": "0.14.0",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3401,7 +3419,7 @@
             "rc": "^1.2.7",
             "rimraf": "^2.6.1",
             "semver": "^5.3.0",
-            "tar": "^4"
+            "tar": "^4.4.2"
           }
         },
         "nopt": {
@@ -3415,13 +3433,22 @@
           }
         },
         "npm-bundled": {
-          "version": "1.0.6",
+          "version": "1.1.1",
+          "bundled": true,
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "npm-normalize-package-bin": "^1.0.1"
+          }
+        },
+        "npm-normalize-package-bin": {
+          "version": "1.0.1",
           "bundled": true,
           "dev": true,
           "optional": true
         },
         "npm-packlist": {
-          "version": "1.4.1",
+          "version": "1.4.7",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3492,7 +3519,7 @@
           "optional": true
         },
         "process-nextick-args": {
-          "version": "2.0.0",
+          "version": "2.0.1",
           "bundled": true,
           "dev": true,
           "optional": true
@@ -3533,7 +3560,7 @@
           }
         },
         "rimraf": {
-          "version": "2.6.3",
+          "version": "2.7.1",
           "bundled": true,
           "dev": true,
           "optional": true,
@@ -3560,7 +3587,7 @@
           "optional": true
         },
         "semver": {
-          "version": "5.7.0",
+          "version": "5.7.1",
           "bundled": true,
           "dev": true,
           "optional": true
@@ -3613,18 +3640,18 @@
           "optional": true
         },
         "tar": {
-          "version": "4.4.8",
+          "version": "4.4.13",
           "bundled": true,
           "dev": true,
           "optional": true,
           "requires": {
             "chownr": "^1.1.1",
             "fs-minipass": "^1.2.5",
-            "minipass": "^2.3.4",
-            "minizlib": "^1.1.1",
+            "minipass": "^2.8.6",
+            "minizlib": "^1.2.1",
             "mkdirp": "^0.5.0",
             "safe-buffer": "^5.1.2",
-            "yallist": "^3.0.2"
+            "yallist": "^3.0.3"
           }
         },
         "util-deprecate": {
@@ -3649,7 +3676,7 @@
           "optional": true
         },
         "yallist": {
-          "version": "3.0.3",
+          "version": "3.1.1",
           "bundled": true,
           "dev": true,
           "optional": true

+ 3 - 22
src/layout/App.tsx

@@ -1,37 +1,18 @@
-import React, { ReactElement, useEffect, useState } from 'react';
+import React, { ReactElement } from 'react';
 import {
   BrowserRouter as Router,
   Route,
   Switch
 } from 'react-router-dom';
 import { CaloriesList } from '../components/caloriesList/CaloriesList';
-import { AppContext } from './AppContext';
+import { AppContextProvider } from './AppContextProvider';
 import { PageFooter } from './pageFooter/PageFooter';
 import { PageHeader } from './pageHeader/PageHeader';
-
 import './app.css';
 
-const AppContextProvider = AppContext.Provider;
-const storedCalories = JSON.parse(localStorage.getItem('calorieItems') || '[]');
-
 function App (): ReactElement {
-  const [calorieItems, setCalorieItems] = useState<CalorieItems>(storedCalories);
-  const [selectedDate, setSelectedDate] = useState<number>(Date.now());
-  const [selectedItem, setSelectedItem] = useState<CalorieValue>();
-
-  useEffect(() => {
-    localStorage.setItem('calorieItems', JSON.stringify(calorieItems));
-  });
-
   return (
-    <AppContextProvider value={{
-      calorieItems,
-      selectedDate,
-      selectedItem,
-      setCalorieItems,
-      setSelectedDate,
-      setSelectedItem
-    }}>
+    <AppContextProvider >
       <PageHeader />
 
       <main id="pageContent">

+ 1 - 1
src/layout/AppContext.ts

@@ -16,7 +16,7 @@ const AppContext = createContext<AppContextType>({
   selectedItem: undefined,
   setCalorieItems: () => [],
   setSelectedDate: () => getDateString(new Date()),
-  setSelectedItem: () => {}
+  setSelectedItem: () => undefined
 });
 
 export {

+ 31 - 0
src/layout/AppContextProvider.tsx

@@ -0,0 +1,31 @@
+import React, { useEffect, useState } from 'react';
+import { AppContext } from './AppContext';
+
+const ContextProvider = AppContext.Provider;
+
+const storedCalories = JSON.parse(localStorage.getItem('calorieItems') || '[]');
+
+function AppContextProvider (props: object) {
+  const [calorieItems, setCalorieItems] = useState<CalorieItems>(storedCalories);
+  const [selectedDate, setSelectedDate] = useState<number>(Date.now());
+  const [selectedItem, setSelectedItem] = useState<CalorieValue>();
+
+  useEffect(() => {
+    localStorage.setItem('calorieItems', JSON.stringify(calorieItems));
+  });
+
+  return (
+    <ContextProvider value={{
+      calorieItems,
+      selectedDate,
+      selectedItem,
+      setCalorieItems,
+      setSelectedDate,
+      setSelectedItem
+    }} {...props} />
+  );
+}
+
+export {
+  AppContextProvider
+};

+ 1 - 1
tslint.json

@@ -10,7 +10,7 @@
         "quotemark": false,
         "space-before-function-paren": false,
         "ordered-imports": [
-            true,
+            false,
             {
                 "import-sources-order": "lowercase-last"
             }