多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
**例子** ``` import React from "react"; const TargetComponet = React.forwardRef((props,ref ) =>( <input type="text" ref={ ref } /> )); export default class Comp extends React.Component{ constructor(props) { super(props); this.ref = React.createRef(); } componentDidMount() { this.ref.current.value = 'ref get input' } render() { return <TargetComponet ref={this.ref} /> } } ``` **源码** ~~~ import {REACT_FORWARD_REF_TYPE, REACT_MEMO_TYPE} from 'shared/ReactSymbols'; export default function forwardRef<Props, ElementType: React$ElementType>( render: (props: Props, ref: React$Ref<ElementType>) => React$Node, ) { return { $$typeof: REACT_FORWARD_REF_TYPE, render, }; } ~~~ > 通过React.ReactElement创建的所有节点都是 REACT_ELEMENT_TYPE