mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 00:36:07 +00:00
perf(ReadPrettyInternalViewer): remove observer
This commit is contained in:
parent
9c0a7e77f3
commit
3241b24042
@ -7,7 +7,7 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
import { RecursionField, useField, useFieldSchema } from '@formily/react';
|
||||||
import { toArr } from '@formily/shared';
|
import { toArr } from '@formily/shared';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { FC, Fragment, useEffect, useRef, useState } from 'react';
|
import React, { FC, Fragment, useEffect, useRef, useState } from 'react';
|
||||||
@ -241,8 +241,7 @@ const getSourceData = (recordData, fieldSchema) => {
|
|||||||
return _.get(recordData, sourceRecordKey);
|
return _.get(recordData, sourceRecordKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ReadPrettyInternalViewer: React.FC = observer(
|
export const ReadPrettyInternalViewer: React.FC<ReadPrettyInternalViewerProps> = (props) => {
|
||||||
(props: ReadPrettyInternalViewerProps) => {
|
|
||||||
const { value, ButtonList = ButtonLinkList } = props;
|
const { value, ButtonList = ButtonLinkList } = props;
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { enableLink } = fieldSchema['x-component-props'] || {};
|
const { enableLink } = fieldSchema['x-component-props'] || {};
|
||||||
@ -250,14 +249,13 @@ export const ReadPrettyInternalViewer: React.FC = observer(
|
|||||||
const field = useField();
|
const field = useField();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { options: collectionField } = useAssociationFieldContext();
|
const { options: collectionField } = useAssociationFieldContext();
|
||||||
const ellipsisWithTooltipRef = useRef<IEllipsisWithTooltipRef>();
|
|
||||||
const { visibleWithURL, setVisibleWithURL } = usePopupUtils();
|
const { visibleWithURL, setVisibleWithURL } = usePopupUtils();
|
||||||
const [btnHover, setBtnHover] = useState(!!visibleWithURL);
|
const [btnHover, setBtnHover] = useState(!!visibleWithURL);
|
||||||
const { defaultOpenMode } = useOpenModeContext();
|
const { defaultOpenMode } = useOpenModeContext();
|
||||||
const recordData = useCollectionRecordData();
|
const recordData = useCollectionRecordData();
|
||||||
|
|
||||||
const btnElement = (
|
const btnElement = (
|
||||||
<EllipsisWithTooltip ellipsis={true} ref={ellipsisWithTooltipRef}>
|
<EllipsisWithTooltip ellipsis={true}>
|
||||||
<CollectionRecordProvider isNew={false} record={getSourceData(recordData, fieldSchema)}>
|
<CollectionRecordProvider isNew={false} record={getSourceData(recordData, fieldSchema)}>
|
||||||
<ButtonList setBtnHover={setBtnHover} value={value} fieldNames={props.fieldNames} />
|
<ButtonList setBtnHover={setBtnHover} value={value} fieldNames={props.fieldNames} />
|
||||||
</CollectionRecordProvider>
|
</CollectionRecordProvider>
|
||||||
@ -303,6 +301,4 @@ export const ReadPrettyInternalViewer: React.FC = observer(
|
|||||||
</ActionContextProvider>
|
</ActionContextProvider>
|
||||||
</PopupVisibleProvider>
|
</PopupVisibleProvider>
|
||||||
);
|
);
|
||||||
},
|
};
|
||||||
{ displayName: 'ReadPrettyInternalViewer' },
|
|
||||||
);
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RecursionField } from '@formily/react';
|
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useCollection } from '../../../../data-source';
|
import { useCollection } from '../../../../data-source';
|
||||||
|
import { NocoBaseRecursionField } from '../../../../formily/NocoBaseRecursionField';
|
||||||
import { useRecord } from '../../../../record-provider';
|
import { useRecord } from '../../../../record-provider';
|
||||||
|
|
||||||
export const ColumnFieldProvider = (props: { schema: any; basePath: any; children: any }) => {
|
export const ColumnFieldProvider = (props: { schema: any; basePath: any; children: any }) => {
|
||||||
@ -45,7 +45,7 @@ export const ColumnFieldProvider = (props: { schema: any; basePath: any; childre
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return <RecursionField basePath={basePath} schema={newSchema} onlyRenderProperties />;
|
return <NocoBaseRecursionField basePath={basePath} schema={newSchema} onlyRenderProperties />;
|
||||||
}
|
}
|
||||||
return props.children;
|
return props.children;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user