【发布时间】:2019-11-07 03:33:34
【问题描述】:
我不明白这是什么意思:
const FancyButton = React.forwardRef((props, ref) => (
<button ref={ref} className="FancyButton">
{props.children}
</button>
));
如果我能做到:
function FancyButton(props) {
return (
<button className="FancyButton" ref={props.ref}>
{props.children}
</button>
);
}
【问题讨论】:
-
您应该在父组件中 createRef 并使用 forwardRef 将其链接到子组件中
标签: javascript node.js reactjs ecmascript-6