-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (39 loc) · 1.06 KB
/
App.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as Redux from "redux";
import * as ReactRedux from "react-redux";
import { Suspense } from "react";
import * as React from "react";
const initialState = { count: 0 };
const reducer = (state = initialState, action) => {
switch (action.type) {
case "increment":
return {
count: state.count + 1,
};
default:
return state;
}
};
const store = Redux.createStore(reducer);
const _Inner = ({ count }) => (
<>
<div>Count: {count}</div>
<Suspense fallback={<div>Loading…</div>}>
<div>Loaded!</div>
</Suspense>
</>
);
const Inner = ReactRedux.connect((state) => ({ count: state.count }))(_Inner);
export class App extends React.Component {
componentDidMount() {
React.startTransition(() => {
store.dispatch({ type: "increment" });
});
}
render() {
return (
<ReactRedux.Provider store={store} serverState={initialState}>
<Inner />
</ReactRedux.Provider>
);
}
}