Add useCallback when testing FunctionalComponent

This commit is contained in:
Jerko Steiner 2019-09-05 13:07:26 +07:00
parent ee6a6741ed
commit 65f8915dc1

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { useCallback } from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { createStore, Dispatch } from 'redux' import { createStore, Dispatch } from 'redux'
@ -34,8 +34,10 @@ describe('pack', () => {
} }
function FunctionalComponent(props: IProps) { function FunctionalComponent(props: IProps) {
const update = useCallback(() => props.update(1, 'one'), [])
return ( return (
<button onClick={() => props.update(1, 'one')}> <button onClick={update}>
{props.a + props.b} {props.a + props.b}
</button> </button>
) )