Skip to content

Commit 3a7ac5c

Browse files
committed
small changes
1 parent d5b4ecc commit 3a7ac5c

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

react/advanced-hooks/05-form-actions/lecture/App.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ export function App() {
4141
const [messages, setMessages] = useState<Message[]>([])
4242
const [pending, setPending] = useState(false)
4343

44-
// // 1. Making this an async function makes little difference
45-
// // 2. However, setting messages state with the fn approach
46-
// // fixes the fact that messages were being overridden
47-
// async function handleSubmit(e: FormEvent<HTMLFormElement>) {
48-
// e.preventDefault()
49-
// setPending(true)
50-
// const formData = new FormData(e.currentTarget)
51-
// messageRef.current.value = ''
52-
// messageRef.current.focus()
53-
// const res = await addMessage(formData.get('messageText') as string)
54-
// const { message: newMessage } = await res.json()
55-
// setMessages((messages) => messages.concat(newMessage))
56-
// setPending(false)
57-
// }
58-
5944
function handleSubmit(e: FormEvent<HTMLFormElement>) {
6045
e.preventDefault()
6146
setPending(true)

react/core/02-state/lecture/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import * as ReactDOM from 'react-dom/client'
33
import { LessonBody, LessonCard } from '~/Lesson'
44
import { Counter } from './Counter'
55

6-
// A nice visual explanation of keys
7-
// https://twitter.com/dan_abramov/status/1415279090446204929
8-
96
function App() {
107
const vacations = [
118
{ id: 1, name: 'Maui', hotels: 5 },
@@ -15,8 +12,7 @@ function App() {
1512
{ id: 5, name: 'Florida Keys', hotels: 1 },
1613
]
1714

18-
// Do "reduce" for total hotels
19-
const totalHotels = 16
15+
const totalHotels = vacations.reduce((sum, item) => sum + item.hotels, 0)
2016

2117
return (
2218
<LessonBody>

react/core/02-state/practice/App.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export function App() {
1111
useState(/* initialState */)
1212

1313
function loadVacations() {
14+
// The getAll() method will resolve an array of vacations. We nest our network API calls
15+
// in objects like api.vacations.getAll() for convenience.
1416
api.vacations.getAll().then((vacations) => {
1517
console.log(vacations)
1618
})

0 commit comments

Comments
 (0)