reactjs - 使用 Modal 框架反应 useRef 钩子
问题描述
我正在学习使用 ReactHooks,需要一些帮助来了解如何将模式的内容分配给 myRef htmlDivElement。
如何将模型的内容分配给 ref 元素。当我执行它时,它是空的,没有任何内容。如何将 Modal 的内容附加到 div 中?
import React, { FunctionComponent, useRef } from "react";
import { Modal } from "antd";
import styles from "./my.module.scss";
export const myComponent: FunctionComponent= () => {
const myRef = useRef<HTMLDivElement>(null);
const DivElement = myRef.current
Display(DivElement);
return (
<div ref={myRef} id="graph_div" className={styles.modal}>
</div>
);
};
const Display = (
DivElement: HTMLDivElement | null
) => {
DivElement.append // Somehow I need this to append the Model element
<Modal
title="Basic Modal"
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
};
当它呈现 id=graph_div 时,其中没有任何内容。它是空的。非常感谢
解决方案
推荐阅读
- sql - SQL 根据两列删除重复记录
- homebrew - 如何重新安装包含所有依赖项的包?
- javascript - 制作了连续的wix灯箱模态
- javascript - 图像不能是数组或对象
- twilio - 如何动态获取呼叫者电话号码并将其作为 Twilio 运行函数 wdget 中的 JSON 键之一传递?
- python - Pandas 使用 apply lambda 和两个不同的运算符
- azure - Terraform - 导入多个 Azure KeyVault 访问策略
- api-gateway - 询问有关编写 krakend config.json 的问题
- maven - 如何释放目标文件夹下的所有工件?
- docker - 在 Docker 上运行 selenium + nodejs