NodeViewWrapper forwardRef

This commit is contained in:
Yousef
2021-06-11 08:04:53 +02:00
committed by GitHub
parent 2502932fa0
commit 83525ec4f1

View File

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