forwardRef

331 阅读1分钟
function forwardRef(render) {
    const elementType = {
      $$typeof: REACT_FORWARD_REF_TYPE,
      render,
    }
    
    return elementType
}
function updateForwardRef(current, workInProgress, Component, nextProps) {
    
    const render = Component.render
    const ref = workInProgress.ref
  
    nextChildren = renderWithHooks(
        current,
        workInProgress,
        render,
        nextProps,
        ref,
    )
       
    reconcileChildren(current, workInProgress, nextChildren)
    return workInProgress.child;
}