我在 api 平台管理中的表单创建和修改渲染不起作用



我的管理面板出现问题。我的api还可以,(可以发布和获取(,但当我想用管理面板创建或更新对象时,我有一个白色表单:屏幕

我的控制台中也有这个警告:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
in IntrospectedFilterGuesser (created by ResourcesIntrospecter)
in ResourcesIntrospecter (created by Introspecter)
in Introspecter (created by FilterGuesser)
in FilterGuesser
in div (created by ForwardRef(Toolbar))
in ForwardRef(Toolbar) (created by WithStyles(ForwardRef(Toolbar)))
in WithStyles(ForwardRef(Toolbar)) (created by TopToolbar)
in TopToolbar (created by ListActions)
in ListActions
in div (created by ForwardRef(Toolbar))
in ForwardRef(Toolbar) (created by WithStyles(ForwardRef(Toolbar)))
in WithStyles(ForwardRef(Toolbar)) (created by ListToolbar)
in ListToolbar (created by ListView)

有人能帮我吗?提前感谢

我没有更改api平台的本地代码。

我的app.js是(REACT_app_API_ENTRYPOINT=https://localhost:8443):

import React from 'react';
import { HydraAdmin } from '@api-platform/admin';
export default () => <HydraAdmin entrypoint={process.env.REACT_APP_API_ENTRYPOINT}/>;

我的api中的nelmio_cors.yaml:

nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization', 'Preload', 'Fields']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null

api中实体的示例:

<?php
namespace AppEntity;
use DoctrineORMMapping as ORM;
/**
* SupplierType
*
* @ORMTable(name="supplier_type")
* @ORMEntity(repositoryClass="AppRepositoryCustomEntityRepository")
*/
class SupplierType
{
/**
* @var int
*
* @ApiResource
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="SEQUENCE")
* @ORMSequenceGenerator(sequenceName="supplier_type_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* @var string
*
* @ORMColumn(name="code", type="string", length=100, nullable=false, unique=true)
*/
private $code;
/**
* @var string
*
* @ORMColumn(name="label", type="string", length=100, nullable=false)
*/
private $label;
/**
* @var DateTime
*
* @ORMColumn(name="created", type="datetime")
*/
private $created;
/**
* @var DateTime
*
* @ORMColumn(name="updated", type="datetime")
*/
private $updated;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getCreated(): ?DateTimeInterface
{
return $this->created;
}
public function setCreated(DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getUpdated(): ?DateTimeInterface
{
return $this->updated;
}
public function setUpdated(DateTimeInterface $updated): self
{
$this->updated = $updated;
return $this;
}
}

您没有共享任何代码,因此很难精确,但您可以尝试跟踪组件是否已安装。

查看此博客文章,它可以提供有关此问题的进一步(更详细(见解:https://www.debuggr.io/react-update-unmounted-component/

此外,这个链接上被接受的答案也可能是相关的:React钩子。可以';t对未安装的组件执行React状态更新

最新更新