Skip to content

Commit

Permalink
⚰️ Remove unnecessary useMemo in useStep
Browse files Browse the repository at this point in the history
  • Loading branch information
juliencrn committed Feb 7, 2024
1 parent 2660580 commit 8325c4e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/usehooks-ts/src/useStep/useStep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useMemo, useState } from 'react'
import { useCallback, useState } from 'react'

import type { Dispatch, SetStateAction } from 'react'

Expand All @@ -25,12 +25,8 @@ type SetStepCallbackType = (step: number | ((step: number) => number)) => void
export function useStep(maxStep: number): [number, Helpers] {
const [currentStep, setCurrentStep] = useState(1)

const canGoToNextStep = useMemo(
() => currentStep + 1 <= maxStep,
[currentStep, maxStep],
)

const canGoToPrevStep = useMemo(() => currentStep - 1 >= 1, [currentStep])
const canGoToNextStep = currentStep + 1 <= maxStep
const canGoToPrevStep = currentStep - 1 > 0

const setStep = useCallback<SetStepCallbackType>(
step => {
Expand Down

0 comments on commit 8325c4e

Please sign in to comment.