- commit
- a2ef831
- parent
- 9bc36df
- author
- Eric Bower
- date
- 2024-03-04 20:02:40 +0000 UTC
docs: getting started
1 files changed,
+4,
-4
+4,
-4
1@@ -78,7 +78,7 @@ import { createApi, createSchema, createStore, mdw, timer } from "starfx";
2 import { Provider, useCache } from "starfx/react";
3
4 const [schema, initialState] = createSchema();
5-const store = createStore(initialState);
6+const store = createStore({ initialState });
7
8 const api = createApi();
9 // mdw = middleware
10@@ -97,15 +97,15 @@ store.run(api.bootup);
11 function App() {
12 return (
13 <Provider schema={schema} store={store}>
14- <App />
15+ <Example />
16 </Provider>
17 );
18 }
19
20 function Example() {
21- const { isLoading, isError, message, data = [] } = useCache(fetchRepo());
22+ const { isLoading, isError, message, data } = useCache(fetchRepo());
23
24- if (isLoading) return "Loading ...";
25+ if (isLoading || !data) return "Loading ...";
26
27 if (isError) return `An error has occurred: ${message}`;
28