Fix issues with the new topic dialog (#8608)

This commit is contained in:
Šimon Brandner 2022-05-16 14:10:00 +02:00 committed by GitHub
parent e1d11db256
commit fb30b67b14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 112 additions and 51 deletions

View file

@ -14,26 +14,31 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { useEffect, useRef } from "react";
import linkifyElement from "linkify-element";
import React, { useLayoutEffect, useRef } from "react";
import { linkifyElement } from "../../../HtmlUtils";
interface Props {
as?: string;
children: React.ReactNode;
onClick?: (ev: MouseEvent) => void;
}
export function Linkify({
as = "div",
children,
onClick,
}: Props): JSX.Element {
const ref = useRef();
useEffect(() => {
useLayoutEffect(() => {
linkifyElement(ref.current);
}, [children]);
return React.createElement(as, {
children,
ref,
onClick,
});
}