Skip to content

Commit

Permalink
improve things a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 21, 2024
1 parent 7b7eb57 commit 893717a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function useToggle() {

return {
on,
toggle,
// 🐨 add your reset function here.
toggle,
getTogglerProps,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export function useToggle({ initialOn = false } = {}) {

return {
on,
toggle,
reset,
toggle,
getTogglerProps,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function useToggle({ initialOn = false } = {}) {

return {
on,
toggle,
reset,
toggle,
getTogglerProps,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function toggleReducer(state: ToggleState, action: ToggleAction) {
}

export function useToggle({ initialOn = false } = {}) {
const initialState = useRef({ on: initialOn }).current
const { current: initialState } = useRef<ToggleState>({ on: initialOn })
const [state, dispatch] = useReducer(toggleReducer, initialState)
const { on } = state

Expand All @@ -45,8 +45,8 @@ export function useToggle({ initialOn = false } = {}) {

return {
on,
toggle,
reset,
toggle,
getTogglerProps,
}
}

0 comments on commit 893717a

Please sign in to comment.