-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient.mjs
32 lines (26 loc) · 813 Bytes
/
client.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// vim: set tw=99 ts=2 sts=2 sw=2 et:
'use strict';
import { createRoot } from 'react-dom/client';
import { Provider, useSelector, useDispatch } from 'react-redux';
import { AiButtons, ChatGptBackend, ThinkingScreen } from 'react-redux-chatgpt';
const initState = { count: 0 };
const backend = new ChatGptBackend(initState);
const App = () => {
const count = useSelector(state => state.count);
const dispatch = useDispatch();
return (
<div>
counter: {count}
<button onClick={() => dispatch({ type: 'increment' })}>increment</button>
</div>
);
};
const root = createRoot(document.getElementById('root'));
root.render(
<Provider store={backend.store}>
<App />
<AiButtons backend={backend} />
<ThinkingScreen useSelector={useSelector} />
</Provider>
);