Commit a54591f2 authored by 张烨's avatar 张烨

fix: upload半受控

parent f1b67a30
......@@ -48,6 +48,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
previewTitle: '',
imgBed: [],
curSelectedImg: '',
prevProps:{},
fileList: this.props.value ? Array.isArray(this.props.value) ? this.props.value.map((v) => ({
url: v,
uid: uuid(8, 16),
......@@ -64,8 +65,9 @@ class PicturesWall extends React.Component<PicturesWallType> {
static getDerivedStateFromProps = (props, state) => {
const fileList = state.fileList;
const shouldUpdate = props.value && fileList.every(f => Array.isArray(props.value) ? !props.value.some(v => f.url === v) : f.url !== props.value)
if(fileList.length === 0 && props.value && shouldUpdate){
if(props.value !== state.prevProps.value && shouldUpdate){
return {
provProps: props,
fileList: Array.isArray(props.value) ? props.value.map((v) => ({
url: v,
uid: uuid(8, 16),
......@@ -79,7 +81,9 @@ class PicturesWall extends React.Component<PicturesWallType> {
}] as UploadFile<any>[]
}
}
return null;
return {
prevProps: props
};
}
update = () =>{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment