Match-id-cf9d94e9056eee2f779cb69c820ebeccdd606f55
This commit is contained in:
parent
02c598d858
commit
95506416dc
|
@ -61,6 +61,7 @@ function captureLazyComponent(
|
|||
if (lazyRender) {
|
||||
if (lazyVNodeTag === MemoComponent) {
|
||||
// Memo要特殊处理
|
||||
processing.effectList = null;
|
||||
const memoVNodeProps = mergeDefaultProps(Component.type, lazyVNodeProps); // 需要整合defaultProps
|
||||
return lazyRender(processing, Component, memoVNodeProps, shouldUpdate);
|
||||
} else {
|
||||
|
|
|
@ -184,4 +184,30 @@ describe('LazyComponent Test', () => {
|
|||
container.querySelector('button').click();
|
||||
expect(container.textContent).toBe('Error: num is 2');
|
||||
});
|
||||
|
||||
it('#24 配合memo', async () => {
|
||||
const fnComp = () => {
|
||||
return <h1>horizon</h1>;
|
||||
};
|
||||
const LazyApp = Horizon.lazy(() => ({
|
||||
then(cb) {
|
||||
cb({ default: Horizon.memo(() => fnComp, false) });
|
||||
},
|
||||
}));
|
||||
expect(() => {
|
||||
Horizon.render(
|
||||
<Horizon.Suspense fallback={<div>Loading...</div>}>
|
||||
<LazyApp text="Lazy" />
|
||||
</Horizon.Suspense>,
|
||||
container
|
||||
);
|
||||
|
||||
Horizon.render(
|
||||
<Horizon.Suspense fallback={<div>Loading...</div>}>
|
||||
<LazyApp text="Lazy" />
|
||||
</Horizon.Suspense>,
|
||||
container
|
||||
);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue