Skip to content

Commit f6c0be7

Browse files
committed
chore(react-dev-overlay): Remove confusingly underscored variables in useErrorOverlayReducer
1 parent c33da53 commit f6c0be7

File tree

1 file changed

+23
-25
lines changed
  • packages/next/src/client/components/react-dev-overlay

1 file changed

+23
-25
lines changed

packages/next/src/client/components/react-dev-overlay/shared.ts

+23-25
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,26 @@ function getInitialState(
140140
}
141141

142142
export function useErrorOverlayReducer(routerType: 'pages' | 'app') {
143-
return useReducer((_state: OverlayState, action: BusEvent): OverlayState => {
143+
return useReducer((state: OverlayState, action: BusEvent): OverlayState => {
144144
switch (action.type) {
145145
case ACTION_DEBUG_INFO: {
146-
return { ..._state, debugInfo: action.debugInfo }
146+
return { ...state, debugInfo: action.debugInfo }
147147
}
148148
case ACTION_STATIC_INDICATOR: {
149-
return { ..._state, staticIndicator: action.staticIndicator }
149+
return { ...state, staticIndicator: action.staticIndicator }
150150
}
151151
case ACTION_BUILD_OK: {
152-
return { ..._state, buildError: null }
152+
return { ...state, buildError: null }
153153
}
154154
case ACTION_BUILD_ERROR: {
155-
return { ..._state, buildError: action.message }
155+
return { ...state, buildError: action.message }
156156
}
157157
case ACTION_BEFORE_REFRESH: {
158-
return { ..._state, refreshState: { type: 'pending', errors: [] } }
158+
return { ...state, refreshState: { type: 'pending', errors: [] } }
159159
}
160160
case ACTION_REFRESH: {
161161
return {
162-
..._state,
162+
...state,
163163
buildError: null,
164164
errors:
165165
// Errors can come in during updates. In this case, UNHANDLED_ERROR
@@ -168,56 +168,54 @@ export function useErrorOverlayReducer(routerType: 'pages' | 'app') {
168168
// around until the next refresh. Otherwise we run into a race
169169
// condition where those errors would be cleared on refresh completion
170170
// before they can be displayed.
171-
_state.refreshState.type === 'pending'
172-
? _state.refreshState.errors
171+
state.refreshState.type === 'pending'
172+
? state.refreshState.errors
173173
: [],
174174
refreshState: { type: 'idle' },
175175
}
176176
}
177177
case ACTION_UNHANDLED_ERROR:
178178
case ACTION_UNHANDLED_REJECTION: {
179-
switch (_state.refreshState.type) {
179+
switch (state.refreshState.type) {
180180
case 'idle': {
181181
return {
182-
..._state,
183-
nextId: _state.nextId + 1,
184-
errors: pushErrorFilterDuplicates(_state.errors, {
185-
id: _state.nextId,
182+
...state,
183+
nextId: state.nextId + 1,
184+
errors: pushErrorFilterDuplicates(state.errors, {
185+
id: state.nextId,
186186
event: action,
187187
}),
188188
}
189189
}
190190
case 'pending': {
191191
return {
192-
..._state,
193-
nextId: _state.nextId + 1,
192+
...state,
193+
nextId: state.nextId + 1,
194194
refreshState: {
195-
..._state.refreshState,
196-
errors: pushErrorFilterDuplicates(_state.refreshState.errors, {
197-
id: _state.nextId,
195+
...state.refreshState,
196+
errors: pushErrorFilterDuplicates(state.refreshState.errors, {
197+
id: state.nextId,
198198
event: action,
199199
}),
200200
},
201201
}
202202
}
203203
default:
204-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
205-
const _: never = _state.refreshState
206-
return _state
204+
return state
207205
}
208206
}
209207
case ACTION_VERSION_INFO: {
210-
return { ..._state, versionInfo: action.versionInfo }
208+
return { ...state, versionInfo: action.versionInfo }
211209
}
212210
case ACTION_DEV_INDICATOR: {
213211
return {
214-
..._state,
212+
...state,
215213
disableDevIndicator:
216214
shouldDisableDevIndicator || !!action.devIndicator.disabledUntil,
217215
}
218216
}
219217
default: {
220-
return _state
218+
return state
221219
}
222220
}
223221
}, getInitialState(routerType))

0 commit comments

Comments
 (0)