The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/views/root/DomNode.tsx

30 lines
602 B

import React, { FC, useLayoutEffect, useRef } from 'react';
type DomNodeProps = {
node: Node;
};
const hiddenStyle = { display: 'none' } as const;
const DomNode: FC<DomNodeProps> = ({ node }) => {
const ref = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
if (!ref.current || !ref.current.parentNode) {
return;
}
const container = ref.current.parentNode;
const sibling = ref.current;
container.insertBefore(node, sibling);
return (): void => {
container.removeChild(node);
};
}, [node]);
return <div ref={ref} style={hiddenStyle} />;
};
export default DomNode;