react-keep-alive
Version:
Package will allow components to maintain their status, to avoid repeated re-rendering.
12 lines (11 loc) • 437 B
JavaScript
import { WithKeepAliveContextConsumerDisplayName } from './withKeepAliveContextConsumer';
export default function getKeyByFiberNode(fiberNode) {
if (!fiberNode) {
return null;
}
var key = fiberNode.key, type = fiberNode.type;
if (type.displayName && type.displayName.indexOf(WithKeepAliveContextConsumerDisplayName) !== -1) {
return key;
}
return getKeyByFiberNode(fiberNode.return);
}