Skip to content

Commit 7da9f14

Browse files
committed
Update index.tsx to use new React API
Fix nesting in <p> in DemoInfo
1 parent a9b0305 commit 7da9f14

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

src/frontend/src/components/Demo/DemoInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DemoInfo extends React.Component {
1010
) => {
1111
return (
1212
<div>
13-
<p className="flex lh-title mb3">
13+
<div className="flex lh-title mb3">
1414
<div className="mr4">
1515
<div className="fw6">First Name</div>
1616
<div>{firstName}</div>
@@ -25,7 +25,7 @@ class DemoInfo extends React.Component {
2525
<div>{dateOfBirth}</div>
2626
</div>
2727
)}
28-
</p>
28+
</div>
2929
{description.map((line: string, idx: number) => (
3030
<p key={idx} className="pb2">
3131
{line}

src/frontend/src/components/Demo/__snapshots__/Demo.test.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ exports[`renders correctly 1`] = `
6666
className="mw7 mb4"
6767
>
6868
<div>
69-
<p
69+
<div
7070
className="flex lh-title mb3"
7171
>
7272
<div
@@ -93,7 +93,7 @@ exports[`renders correctly 1`] = `
9393
Conviction
9494
</div>
9595
</div>
96-
</p>
96+
</div>
9797
<p
9898
className="pb2"
9999
>
@@ -112,7 +112,7 @@ exports[`renders correctly 1`] = `
112112
className="mw7 mb4"
113113
>
114114
<div>
115-
<p
115+
<div
116116
className="flex lh-title mb3"
117117
>
118118
<div
@@ -139,7 +139,7 @@ exports[`renders correctly 1`] = `
139139
Charges
140140
</div>
141141
</div>
142-
</p>
142+
</div>
143143
<p
144144
className="pb2"
145145
>
@@ -163,7 +163,7 @@ exports[`renders correctly 1`] = `
163163
className="mw7 mb4"
164164
>
165165
<div>
166-
<p
166+
<div
167167
className="flex lh-title mb3"
168168
>
169169
<div
@@ -190,7 +190,7 @@ exports[`renders correctly 1`] = `
190190
Common
191191
</div>
192192
</div>
193-
</p>
193+
</div>
194194
<p
195195
className="pb2"
196196
>
@@ -214,7 +214,7 @@ exports[`renders correctly 1`] = `
214214
className="mw7 mb4"
215215
>
216216
<div>
217-
<p
217+
<div
218218
className="flex lh-title mb3"
219219
>
220220
<div
@@ -251,7 +251,7 @@ exports[`renders correctly 1`] = `
251251
1/1/1970
252252
</div>
253253
</div>
254-
</p>
254+
</div>
255255
<p
256256
className="pb2"
257257
>
@@ -270,7 +270,7 @@ exports[`renders correctly 1`] = `
270270
className="mw7 mb4"
271271
>
272272
<div>
273-
<p
273+
<div
274274
className="flex lh-title mb3"
275275
>
276276
<div
@@ -307,7 +307,7 @@ exports[`renders correctly 1`] = `
307307
2/2/1985
308308
</div>
309309
</div>
310-
</p>
310+
</div>
311311
<p
312312
className="pb2"
313313
>

src/frontend/src/index.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// These imports are all defaults from create-react-app.
2-
import React from "react";
3-
import ReactDOM from "react-dom";
4-
import App from "./components/App";
5-
import * as serviceWorker from "./serviceWorker";
6-
import "./index.scss";
7-
8-
// The following is based on the example code at
9-
// https://react-redux.js.org/introduction/quick-start
2+
import { createRoot } from "react-dom/client";
103
import { Provider } from "react-redux";
4+
import { BrowserRouter } from "react-router-dom";
5+
6+
import * as serviceWorker from "./serviceWorker";
117
import store from "./redux/store";
8+
import App from "./components/App";
9+
import "./index.scss";
1210

13-
const rootElement = document.getElementById("root");
14-
ReactDOM.render(
11+
const container = document.getElementById("root");
12+
const root = createRoot(container!);
13+
root.render(
1514
<Provider store={store}>
16-
<App />
17-
</Provider>,
18-
rootElement
15+
<BrowserRouter>
16+
<App />
17+
</BrowserRouter>
18+
</Provider>
1919
);
2020

2121
// Service Workers are intentionally turned off; they were causing

src/frontend/src/redux/store.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// See the following guides for an explanation:
21
// https://redux-starter-kit.js.org/usage/usage-guide
32
// https://redux.js.org/recipes/usage-with-typescript
4-
import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
5-
import { combineReducers } from "redux";
63

7-
// Reducers:
4+
import { configureStore } from "@reduxjs/toolkit";
5+
import { combineReducers } from "redux";
86
import { searchReducer } from "./search/reducer";
97

108
const rootReducer = combineReducers({
@@ -13,9 +11,9 @@ const rootReducer = combineReducers({
1311

1412
const store = configureStore({
1513
reducer: rootReducer,
16-
middleware: [...getDefaultMiddleware()],
1714
});
1815

1916
export type AppState = ReturnType<typeof rootReducer>;
20-
17+
export type RootState = ReturnType<typeof store.getState>;
18+
export type AppDispatch = typeof store.dispatch;
2119
export default store;

0 commit comments

Comments
 (0)