File tree Expand file tree Collapse file tree 2 files changed +2
-7
lines changed
react/advanced-hooks/01-useEffect/practice-chat-room Expand file tree Collapse file tree 2 files changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -90,11 +90,7 @@ export function ChatRoom({ user }: Props) {
90
90
const e = event . target
91
91
// See if the user scrolled to the bottom
92
92
const bottom = e . scrollHeight <= Math . ceil ( e . scrollTop + e . clientHeight )
93
- // If the user is in a different scroll position from what we have
94
- // in state, update the state
95
- if ( scrolledToBottom !== bottom ) {
96
- setScrolledToBottom ( bottom )
97
- }
93
+ setScrolledToBottom ( bottom )
98
94
}
99
95
100
96
return (
Original file line number Diff line number Diff line change @@ -58,8 +58,7 @@ export function ChatRoom({ user }: Props) {
58
58
const e = event . target
59
59
// See if the user scrolled to the bottom
60
60
const bottom = e . scrollHeight <= Math . ceil ( e . scrollTop + e . clientHeight )
61
- // If the user is in a different scroll position from what we have
62
- // in state, update the state
61
+ // ⭐️⭐️⭐️ Let's talk about this if-statement and why it's actually not needed
63
62
if ( scrolledToBottom !== bottom ) {
64
63
setScrolledToBottom ( bottom )
65
64
}
You can’t perform that action at this time.
0 commit comments