about summary refs log tree commit diff
path: root/src/components/hooks/useInteractionState.ts
blob: 67042d4a8cfa661f580e5180fe60386e76fc865b (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)
  }, [])
  const onOut = React.useCallback(() => {
    setState(false)
  }, [])

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