-
Notifications
You must be signed in to change notification settings - Fork 4
[FhirResourceTree] Reset tree state on unmount #661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this deserves a test ? shoudn't all side effects be tested ?
useEffect(() => { | ||
return () => { | ||
if (!node) { | ||
dispatch(resourceTreeSliceStateReseted()); | ||
} | ||
}; | ||
}, [dispatch, node]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useEffect(() => { | |
return () => { | |
if (!node) { | |
dispatch(resourceTreeSliceStateReseted()); | |
} | |
}; | |
}, [dispatch, node]); | |
useEffect(() => () => !node && dispatch(resourceTreeSliceStateReseted()), | |
[dispatch, node]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to test whether this reset action has been called once when hook is unmounted
259777a
to
6c9131a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
server.listen({ onUnhandledRequest: "error" }); | ||
}); | ||
|
||
describe("useFhirResourceTreeData", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! looks simple
6c9131a
to
cac3752
Compare
Fixes
Definition of Done