mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
fix: 修复 inputFile 中 receiver 获取的数据没有更新的问题 (#3529)
This commit is contained in:
parent
e87fe135af
commit
af8459b9cf
@ -9,7 +9,12 @@ import {Payload, ApiObject, ApiString, Action} from '../../types';
|
||||
import {filter} from '../../utils/tpl';
|
||||
import Alert from '../../components/Alert2';
|
||||
import {qsstringify, createObject, guid, isEmpty} from '../../utils/helper';
|
||||
import {buildApi, normalizeApi} from '../../utils/api';
|
||||
import {
|
||||
buildApi,
|
||||
isEffectiveApi,
|
||||
normalizeApi,
|
||||
isApiOutdated
|
||||
} from '../../utils/api';
|
||||
import Button from '../../components/Button';
|
||||
import {Icon} from '../../components/icons';
|
||||
import DropZone from 'react-dropzone';
|
||||
@ -1421,6 +1426,14 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
@FormItem({
|
||||
type: 'input-file',
|
||||
sizeMutable: false,
|
||||
renderDescription: false
|
||||
renderDescription: false,
|
||||
shouldComponentUpdate: (props: any, prevProps: any) =>
|
||||
!!isEffectiveApi(props.receiver, props.data) &&
|
||||
isApiOutdated(
|
||||
props.receiver,
|
||||
prevProps.receiver,
|
||||
props.data,
|
||||
prevProps.data
|
||||
)
|
||||
})
|
||||
export class FileControlRenderer extends FileControl {}
|
||||
|
@ -291,6 +291,7 @@ export interface FormItemBasicConfig extends Partial<RendererConfig> {
|
||||
storeType?: string;
|
||||
validations?: string;
|
||||
strictMode?: boolean;
|
||||
shouldComponentUpdate?: (props: any, prevProps: any) => boolean;
|
||||
descriptionClassName?: string;
|
||||
storeExtendsData?: boolean;
|
||||
sizeMutable?: boolean;
|
||||
@ -1187,7 +1188,11 @@ export function asFormItem(config: Omit<FormItemConfig, 'component'>) {
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: FormControlProps) {
|
||||
if (nextProps.strictMode === false || config.strictMode === false) {
|
||||
if (
|
||||
config.shouldComponentUpdate?.(this.props, nextProps) ||
|
||||
nextProps.strictMode === false ||
|
||||
config.strictMode === false
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user