Skip to content

Commit

Permalink
fix(mouse): wrap value in useMemo hook
Browse files Browse the repository at this point in the history
  • Loading branch information
FradSer committed May 4, 2023
1 parent f78228f commit ca65957
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions contexts/Mouse/MouseContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode, useState } from 'react'
import { ReactNode, useState, useMemo } from 'react'

import { MouseContext } from '@/contexts/Mouse/MouseContext'

Expand All @@ -13,10 +13,12 @@ export default function MouseContextProvider({ children }: MouseContextProps) {
setCursorType(cursorType)
}

const value = {
cursorType: cursorType,
cursorChangeHandler: cursorChangeHandler,
}
const value = useMemo(() => {
return {
cursorType: cursorType,
cursorChangeHandler: cursorChangeHandler,
}
}, [cursorType])

return <MouseContext.Provider value={value}>{children}</MouseContext.Provider>
}

0 comments on commit ca65957

Please sign in to comment.