fix hooks deps

This commit is contained in:
Pig Fang 2020-01-27 11:50:29 +08:00
parent 7c144b3e14
commit 999167e11e
3 changed files with 11 additions and 5 deletions

View File

@ -74,7 +74,6 @@ const Modal = React.forwardRef<HTMLDivElement, ModalOptions & Props>(
useEffect(() => {
const onHide = () => {
/* istanbul ignore else */
if (!hidden) {
dismiss()
}
@ -87,7 +86,7 @@ const Modal = React.forwardRef<HTMLDivElement, ModalOptions & Props>(
return () => {
el.off('hide.bs.modal', onHide).off('hidden.bs.modal', onHidden)
}
}, [])
}, [hidden, props.onDismiss])
return (
<div

View File

@ -24,12 +24,12 @@ const InfoBox: React.FC<Props> = props => {
props.onDisable(plugin)
}
},
[],
[plugin],
)
const handleDelete = useCallback(() => {
props.onDelete(plugin)
}, [])
}, [plugin])
return (
<div className={`info-box mr-3 ${styles.box}`}>

View File

@ -32,7 +32,14 @@ test('forward ref', () => {
test('jQuery events', () => {
const ref = React.createRef<HTMLDivElement>()
render(<Modal ref={ref} show />)
const { getByText } = render(<Modal ref={ref} mode="confirm" show />)
act(() => {
$(ref.current!)
.trigger('hide.bs.modal')
.trigger('hidden.bs.modal')
})
fireEvent.click(getByText(trans('general.cancel')))
act(() => {
$(ref.current!)
.trigger('hide.bs.modal')