import * as React from 'react' ; interface MethodsProps { increment : ( ) => void ; decrement : ( ) => void ; incrementBy : ( step : number ) => void ; decrementBy : ( step : number ) => void ; } const { useState } = React ; function useCounter ( initialValue ) { const [ count , setCount ] = useState ( initialValue ) ; const incrementBy = ( step ) => { setCount ( count + step ) ; } ; const decrementBy = ( step ) => { setCount ( count - step ) ; } ; const increment = ( ) => { setCount ( count + 1 ) ; } ; const decrement = ( ) => { setCount ( count - 1 ) ; } ; return [ count , { increment , decrement , decrementBy , incrementBy } ] ; } export default useCounter ;