We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca288fa commit f42f6d1Copy full SHA for f42f6d1
src/test.js
@@ -25,6 +25,10 @@ const Component = props => {
25
setComponentState('Mounted')
26
})
27
28
+ useComponentDidUpdate((prevState, prevProps) => {
29
+ if (props.data !== prevProps.data) setComponentState('Updated')
30
+ })
31
+
32
return (
33
<div id='component'>
34
<p>{componentState}</p>
@@ -47,4 +51,13 @@ describe('Test useLifecycleHelpers custom hook', () => {
47
51
48
52
getByText(/Mounted/i)
49
53
54
55
+ test('The component should be updated', () => {
56
+ const { getByText, rerender } = renderComponent({ data: 'test1' })
57
58
+ const newProps = { data: 'test2' }
59
+ rerender(<Component {...newProps} />)
60
61
+ getByText(/Updated/i)
62
50
63
0 commit comments