NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
*Ref forwarding*是一个特性,它允许一些组件获取接收到*ref*对象并将它进一步传递给子组件。 ~~~js const ButtonElement = React.forwardRef((props, ref) => ( <button ref={ref} className="CustomButton"> {props.children} </button> )); // Create ref to the DOM button: const ref = React.createRef(); <ButtonElement ref={ref}>{'Forward Ref'}</ButtonElement> ~~~ ## 参考 [react面试题](https://github.com/semlinker/reactjs-interview-questions)