fix component slot will not update after property change bug

This commit is contained in:
Bowen Tan 2022-01-12 10:43:24 +08:00
parent 0980215be5
commit 2964dea1e2

View File

@ -2,10 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { merge } from 'lodash-es';
import { RuntimeComponentSchema, RuntimeTraitSchema } from '@sunmao-ui/core';
import { watch } from '../../utils/watchReactivity';
import {
ImplWrapperProps,
TraitResult,
} from '../../types';
import { ImplWrapperProps, TraitResult } from '../../types';
import { shallowCompareArray } from '../../utils/shallowCompareArray';
const _ImplWrapper = React.forwardRef<HTMLDivElement, ImplWrapperProps>((props, ref) => {
@ -227,12 +224,13 @@ export const ImplWrapper = React.memo<ImplWrapperProps>(
(prevProps, nextProps) => {
const prevChildren = prevProps.childrenMap[prevProps.component.id]?._grandChildren;
const nextChildren = nextProps.childrenMap[nextProps.component.id]?._grandChildren;
if (!prevChildren || !nextProps) return false;
const prevComponent = prevProps.component;
const nextComponent = nextProps.component;
let isEqual = false;
if (prevChildren && nextChildren) {
isEqual = shallowCompareArray(prevChildren, nextChildren);
}
return isEqual;
return isEqual && prevComponent === nextComponent;
}
);