about summary refs log tree commit diff
path: root/src/components/hooks/useInteractionState.ts
blob: 653b1c10e65cd1d49738a7de3b3d241d3090df32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import React from 'react'

export function useInteractionState() {
  const [state, setState] = React.useState(false)

  const onIn = React.useCallback(() => {
    setState(true)
  }, [setState])
  const onOut = React.useCallback(() => {
    setState(false)
  }, [setState])

  return React.useMemo(
    () => ({
      state,
      onIn,
      onOut,
    }),
    [state, onIn, onOut],
  )
}