repos / starfx

a micro-mvc framework for react apps
git clone https://github.com/neurosnap/starfx.git

starfx / examples / vite-react / src
Eric Bower  ·  2025-06-06

App.tsx

 1import {
 2  TypedUseSelectorHook,
 3  useDispatch,
 4  useSelector as useSel,
 5} from "starfx/react";
 6import "./App.css";
 7import { AppState, fetchUsers, schema } from "./api.ts";
 8
 9const useSelector: TypedUseSelectorHook<AppState> = useSel;
10
11function App({ id }: { id: string }) {
12  const dispatch = useDispatch();
13  const user = useSelector((s) => schema.users.selectById(s, { id }));
14  const userList = useSelector(schema.users.selectTableAsList);
15  return (
16    <div>
17      <div>hi there, {user.name}</div>
18      <button onClick={() => dispatch(fetchUsers())}>Fetch users</button>
19      {userList.map((u) => {
20        return <div key={u.id}>({u.id}) {u.name}</div>;
21      })}
22    </div>
23  );
24}
25
26export default App;