Add useCallback when testing FunctionalComponent
This commit is contained in:
parent
ee6a6741ed
commit
65f8915dc1
@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user