|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState } from 'react';
|
|
|
+import React, { useState, useEffect } from 'react';
|
|
|
import { Button } from '@d8d/shared-ui-components/components/ui/button';
|
|
|
import { Card, CardContent } from '@d8d/shared-ui-components/components/ui/card';
|
|
|
import { Label } from '@d8d/shared-ui-components/components/ui/label';
|
|
|
@@ -30,6 +30,11 @@ export const PhotoUploadField: React.FC<PhotoUploadFieldProps> = ({
|
|
|
}) => {
|
|
|
const [photos, setPhotos] = useState<PhotoItem[]>(value);
|
|
|
|
|
|
+ // 同步外部value变化
|
|
|
+ useEffect(() => {
|
|
|
+ setPhotos(value);
|
|
|
+ }, [value]);
|
|
|
+
|
|
|
const handleAddPhoto = () => {
|
|
|
if (photos.length >= maxPhotos) {
|
|
|
toast.warning(`最多只能上传 ${maxPhotos} 张照片`);
|