1. 程式人生 > 其它 >umijs控制檯報錯:Warning: Cannot update during an existing state transition (such as within `render`).

umijs控制檯報錯:Warning: Cannot update during an existing state transition (such as within `render`).

技術標籤:前端

import React from 'react'
import {Modal, Button,Form, Input } from 'antd';

export const UserModal=(props)=>{
    const [form] = Form.useForm();

    form.setFieldsValue(props.record);
...

原來的程式碼改成這樣

import React,{useEffect} from 'react'
import {Modal, Button,Form, Input } from 'antd';

export const UserModal=(props)=>{
    const [form] = Form.useForm();

    useEffect(()=>{
        form.setFieldsValue(props.record);
    },[props.visible])
...