Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react testing library for hooks

import { useState, useCallback } from 'react'

function useCounter() {
  const [count, setCount] = useState(0)

  const increment = useCallback(() => setCount((x) => x + 1), [])

  return { count, increment }
}

export default useCounter
Source by github.com #
 
PREVIOUS NEXT
Tagged: #react #testing #library #hooks
ADD COMMENT
Topic
Name
4+1 =