Skip to content

Commit

Permalink
feat: add new cache from diff origin component
Browse files Browse the repository at this point in the history
  • Loading branch information
liujuping authored and JackLian committed Jul 11, 2023
1 parent 60545d1 commit bf7b0b3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/renderer-core/src/hoc/leaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
getNode,
});

if (curDocumentId && cache.component.has(componentCacheId)) {
return cache.component.get(componentCacheId);
if (curDocumentId && cache.component.has(componentCacheId) && (cache.component.get(componentCacheId).Comp === Comp)) {
return cache.component.get(componentCacheId).LeafWrapper;
}

class LeafHoc extends Component {
Expand Down Expand Up @@ -590,7 +590,10 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {

LeafWrapper.displayName = (Comp as any).displayName;

cache.component.set(componentCacheId, LeafWrapper);
cache.component.set(componentCacheId, {
LeafWrapper,
Comp,
});

return LeafWrapper;
}

0 comments on commit bf7b0b3

Please sign in to comment.