run(listener, [LIFECYCLE_ACTIVATE]))
}
@@ -42,22 +48,6 @@ export default class Keeper extends Component {
.forEach(([, listener]) => run(listener, [LIFECYCLE_UNACTIVATE]))
}
- // Error Boundary 透传至对应 KeepAlive 实例
- static getDerivedStateFromError = error => null
- componentDidCatch(error) {
- const { id, store } = this.props
-
- const cache = store.get(id)
- const instance = get(cache, 'keepAliveInstance')
-
- if (instance) {
- instance.catchError = error
- instance.forceUpdate(() => {
- delete instance.catchError
- })
- }
- }
-
// // 原先打算更新过程中先重置 dom 节点状态,更新后恢复 dom 节点
// // 但考虑到性能消耗可能过大,且可能因 dom 操作时机引发其他 react 渲染问题,故不使用
// // 对应 KeepAlive 处 update 也注释起来不使用
@@ -106,7 +96,7 @@ export default class Keeper extends Component {
}
render() {
- const { ctx$$, id, children, ...props } = this.props
+ const { id, children, bridgeProps, ...props } = this.props
return (
)
diff --git a/src/core/getKeyByFiberNode.js b/src/core/getKeyByFiberNode.js
index ed50999..1f1e3f1 100644
--- a/src/core/getKeyByFiberNode.js
+++ b/src/core/getKeyByFiberNode.js
@@ -33,6 +33,7 @@ const genRenderPath = node => {
}
// 使用节点 _ka 属性或下标与其 key 作为 Y 坐标
+// FIXME: 使用 index 作为 Y 坐标是十分不可靠的行为,待想出更好的法子替代
const getNodeId = fiberNode =>
`${get(fiberNode, 'pendingProps._ka', fiberNode.index)}:${fiberNode.key ||
''}`
diff --git a/src/core/lifecycles.js b/src/core/lifecycles.js
index 0a1a3cf..efd623f 100644
--- a/src/core/lifecycles.js
+++ b/src/core/lifecycles.js
@@ -7,7 +7,14 @@ import React, {
} from 'react'
import hoistStatics from 'hoist-non-react-statics'
-import { get, run, nextTick, isObject, isFunction, isUndefined } from '../helpers'
+import {
+ get,
+ run,
+ nextTick,
+ isObject,
+ isFunction,
+ isUndefined
+} from '../helpers'
import { AliveNodeConsumer, aliveNodeContext } from './context'
diff --git a/src/core/withAliveScope.js b/src/core/withAliveScope.js
index a50575a..7789e47 100644
--- a/src/core/withAliveScope.js
+++ b/src/core/withAliveScope.js
@@ -3,17 +3,17 @@ import hoistStatics from 'hoist-non-react-statics'
import { isFunction } from '../helpers'
-import { ConsumerBridge } from './ContextBridge'
+import { Acceptor } from './Bridge'
import AliveIdProvider from './AliveIdProvider'
import { AliveScopeConsumer, aliveScopeContext } from './context'
export const expandKeepAlive = KeepAlive => {
const renderContent = ({ id, helpers, props }) => (
-
- {ctxValue => (
-
+
+ {bridgeProps => (
+
)}
-
+
)
function HookExpand(props) {
diff --git a/src/index.js b/src/index.js
index b33a23f..696178d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,7 +1,7 @@
import AliveScope from './core/AliveScope'
import { withActivation, useActivate, useUnactivate } from './core/lifecycles'
import KeepAlive from './core/KeepAlive'
-import { fixContext, createContext } from './core/ContextBridge'
+import { fixContext, createContext } from './core/Bridge/Context'
import withAliveScope, { useAliveController } from './core/withAliveScope'
export default KeepAlive