NodeViewWrapper forwardRef

This commit is contained in:
Yousef 2021-06-11 08:04:53 +02:00 committed by GitHub
parent 2502932fa0
commit 83525ec4f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,19 +6,22 @@ export interface NodeViewWrapperProps {
as?: React.ElementType,
}
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
const { onDragStart } = useReactNodeView()
const Tag = props.as || 'div'
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> =
React.forwardRef((props, ref) => {
const { onDragStart } = useReactNodeView()
const Tag = props.as || 'div'
return (
<Tag
{...props}
data-node-view-wrapper=""
onDragStart={onDragStart}
style={{
...props.style,
whiteSpace: 'normal',
}}
/>
)
return (
<Tag
{...props}
ref={ref}
data-node-view-wrapper=""
onDragStart={onDragStart}
style={{
...props.style,
whiteSpace: 'normal',
}}
/>
)
}
}