Skip to content

Commit

Permalink
Remove unnecessary event argument from notice onRemove function.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jan 21, 2025
1 parent 5ed5eff commit db98650
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/js/components/SnippetForm/page/Notices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ import classnames from 'classnames'
import React, { useEffect } from 'react'
import { __, sprintf } from '@wordpress/i18n'
import { useSnippetForm } from '../../../hooks/useSnippetForm'
import type { MouseEventHandler, ReactNode} from 'react'
import type { ReactNode } from 'react'

interface DismissibleNoticeProps {
classNames?: classnames.Argument
onRemove: MouseEventHandler<HTMLButtonElement>
onRemove: VoidFunction
children?: ReactNode
autoHide?: boolean
}

const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ classNames, onRemove, children, autoHide = true }) => {
useEffect(() => {
if (autoHide) {
const timer = setTimeout(() => {
onRemove({} as React.MouseEvent<HTMLButtonElement>)
}, 5000)

const timer = setTimeout(onRemove, 5000)
return () => clearTimeout(timer)
}
return () => {} // eslint-disable-line
return undefined
}, [autoHide, onRemove])

return (
Expand All @@ -29,7 +26,7 @@ const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ classNames, onRem

<button type="button" className="notice-dismiss" onClick={event => {
event.preventDefault()
onRemove(event)
onRemove()
}}>
<span className="screen-reader-text">{__('Dismiss notice.', 'code-snippets')}</span>
</button>
Expand Down

0 comments on commit db98650

Please sign in to comment.