Renderer 更新不检测 scope 变化

This commit is contained in:
2betop 2019-12-26 11:05:39 +08:00
parent 6accf51276
commit b68a644070
1 changed files with 11 additions and 3 deletions

View File

@ -461,10 +461,14 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
// 限制:只有 schema 除外的 props 变化,或者 schema 里面的某个成员值发生变化才更新。
shouldComponentUpdate(nextProps: SchemaRendererProps) {
const props = this.props;
const list: Array<string> = difference(Object.keys(nextProps), ['schema']);
const list: Array<string> = difference(Object.keys(nextProps), [
'schema',
'scope'
]);
if (
difference(Object.keys(props), ['schema']).length !== list.length ||
difference(Object.keys(props), ['schema', 'scope']).length !==
list.length ||
anyChanged(list, this.props, nextProps)
) {
return true;
@ -763,7 +767,11 @@ export function HocStoreFactory(renderer: {
...store.data
})
);
} else if (props.scope !== nextProps.scope) {
} else if (
nextProps.scope &&
nextProps.data === nextProps.store!.data &&
props.data !== nextProps.data
) {
store.initData(
createObject(nextProps.scope, {
// ...nextProps.data,