浏览代码

fix(ui): 修复编辑表单照片显示问题

- 在PhotoUploadField组件中添加useEffect同步外部value变化
- 确保编辑表单加载照片数据后能正确显示在组件中
- 修复组件状态与props不同步的问题

🤖 Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 1 天之前
父节点
当前提交
7249c4226d
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      allin-packages/disability-person-management-ui/src/components/PhotoUploadField.tsx

+ 6 - 1
allin-packages/disability-person-management-ui/src/components/PhotoUploadField.tsx

@@ -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} 张照片`);