Skip to content

Commit

Permalink
refactor(core/form/inputs): function can now be moved out of scope
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Dec 20, 2022
1 parent 3fd22cc commit ccdc0fd
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -97,18 +97,21 @@ export function BlockObject(props: BlockObjectProps) {
setTimeout(() => PortableTextEditor.focus(editor))
}, [editor, path])

const blockPreview = useMemo(() => {
const _handleDelete = (e: React.MouseEvent<Element, MouseEvent>) => {
const handleDelete = useCallback(
(e: React.MouseEvent<Element, MouseEvent>) => {
e.preventDefault()
e.stopPropagation()
onRemove()
}
},
[onRemove]
)

const blockPreview = useMemo(() => {
return (
<BlockObjectPreview
focused={focused}
isActive={isActive}
// eslint-disable-next-line react/jsx-no-bind
onClickingDelete={_handleDelete}
onClickingDelete={handleDelete}
onClickingEdit={openItem}
readOnly={readOnly}
renderPreview={renderPreview}
Expand Down

0 comments on commit ccdc0fd

Please sign in to comment.