Fix issues with the new topic dialog (#8608)
This commit is contained in:
parent
e1d11db256
commit
fb30b67b14
8 changed files with 112 additions and 51 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue