Skip to content

Commit a61f5cb

Browse files
committed
fix: just use swr
1 parent e15f649 commit a61f5cb

File tree

5 files changed

+32
-84
lines changed

5 files changed

+32
-84
lines changed

package-lock.json

Lines changed: 23 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
"@types/jquery": "^3.3.30",
206206
"@types/mocha": "^5.2.6",
207207
"@types/node": "^10.12.21",
208-
"@types/react": "^18.0.26",
208+
"@types/react": "^17.0.52",
209209
"@types/vscode": "^1.74.0",
210210
"@typescript-eslint/eslint-plugin": "^5.47.1",
211211
"@typescript-eslint/parser": "^5.47.1",
@@ -259,6 +259,7 @@
259259
"node-fetch": "^2.6.7",
260260
"react": "^17.0.2",
261261
"react-vsc-treeview": "^0.2.3",
262-
"string": "git+ssh://[email protected]/hackmdio/string.js.git#a68176b3d"
262+
"string": "git+ssh://[email protected]/hackmdio/string.js.git#a68176b3d",
263+
"swr": "^1.3.0"
263264
}
264265
}

src/treeReactApp/pages/History.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import useSWR from 'swr';
2+
13
import { API } from '../../api';
24
import { NoteTreeItem } from '../components/NoteTreeItem';
3-
import { usePromise } from '../utils/usePromise';
45

56
export const History = () => {
67
// TODO: mutate history list on refresh
7-
const { data = [] } = usePromise(() => API.getHistory(), ['history']);
8+
const { data = [] } = useSWR('history', () => API.getHistory());
89

910
return (
1011
<>

src/treeReactApp/pages/MyNotes.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import useSWR from 'swr';
2+
13
import { API } from '../../api';
24
import { NoteTreeItem } from '../components/NoteTreeItem';
3-
import { usePromise } from '../utils/usePromise';
45

56
export const MyNotes = () => {
6-
const { data = [] } = usePromise(() => API.getNoteList(), ['myNotes']);
7+
const { data = [] } = useSWR('/my-notes', () => API.getNoteList());
78

89
return (
910
<>

src/treeReactApp/utils/usePromise.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)