我正在尝试使用库在todo应用程序中拖放列表,但是我一直在控制台中得到这三个错误。
错误1:
Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `Droppable`.
错误2:
Function components cannot be given refs. Attempts to access this ref will fail. Did y
我有以下(使用资料用户界面)..。
import React from "react";
import { NavLink } from "react-router-dom";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
function LinkTab(link){
return <Tab component={NavLink}
to={link.link}
l
在尝试通过input (或任何其他非样式组件,例如SwitchUnstyled、SelectUnstyled等)自定义该组件时,我会收到警告
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `ForwardRef`.
InputElement@http://localhost:3000/main.4c2d885b9953394bb
这是我用forwardRef定制的组件。ref在组件内部代码中是必需的,但父组件可以选择将其作为道具发送
const MyComponent = React.forwardRef((props, ref) => {
const handleButtonClick = () => {
// I need to access the ref here but, it's null
// when I not pass ref as prop to my component
}
return (
<
虽然我已经应用了forwardRef在几个帖子和材料用户界面网站的例子中提到,但我仍然有警告在控制台。我真的不明白为什么。
我正在尝试创建一个抽屉,其中包含一个项目列表,这些项目是嵌入到Material链接组件中的路由器链接。我嵌入它们是为了从我创建的全局MUI主题中获益
PS :这是打字码。强打字是地狱;-)
链路组件
import { Link as MUILink, LinkBaseProps } from "@material-ui/core";
import React from "react";
import {
Link as LinkRou