Eric Bower
·
2025-06-06
main.tsx
1import React from "react";
2import ReactDOM from "react-dom/client";
3import { createStore, take } from "starfx";
4import { Provider } from "starfx/react";
5import { api, initialState, schema } from "./api.ts";
6import App from "./App.tsx";
7import "./index.css";
8
9init();
10
11function init() {
12 const store = createStore({ initialState });
13 // makes `fx` available in devtools
14 (window as any).fx = store;
15
16 store.run([
17 function* logger() {
18 while (true) {
19 const action = yield* take("*");
20 console.log("action", action);
21 }
22 },
23 api.register,
24 ]);
25
26 ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
27 <React.StrictMode>
28 <Provider schema={schema} store={store}>
29 <App id="1" />
30 </Provider>
31 </React.StrictMode>,
32 );
33}