Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e99d3f6

Browse files
committed
获取_reactInternals 以及 _reactInternalFiber
1 parent 60113dc commit e99d3f6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/applyVueInReact.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const VueContainer = React.forwardRef((props, ref) => {
6363
const TargetComponent = reactRouterInfo.withRouter(GetReactRouterPropsCom)
6464
// withRouter方法是通过wrappedComponentRef来传递ref的
6565
return (
66-
<TargetComponent {...{...props, [optionsName]: globalOptions}} forwardRef={ref} />
66+
<TargetComponent {...{...props, [optionsName]: globalOptions}} forwardRef={ref} />
6767
)
6868
} else {
6969
return <VueComponentLoader {...{...props, [optionsName]: globalOptions}} ref={ref}/>
@@ -440,7 +440,9 @@ class VueComponentLoader extends React.Component {
440440
Vue.nextTick(() => {
441441
const targetId = '__vue_wrapper_container_' + (Math.random() + '').substr(2)
442442
targetElement.id = targetId
443-
let parentInstance = this._reactInternals.return
443+
// 获取react的fiber实例
444+
const fiberNode = this._reactInternals || this._reactInternalFiber
445+
let parentInstance = fiberNode.return
444446
let vueWrapperRef
445447
// 向上查找react包囊层
446448
while (parentInstance) {

0 commit comments

Comments
 (0)