reactjs - 我在 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 App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SupplierType
*
* @ORM\Table(name="supplier_type")
* @ORM\Entity(repositoryClass="App\Repository\CustomEntityRepository")
*/
class SupplierType
{
/**
* @var int
*
* @ApiResource
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="supplier_type_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=100, nullable=false, unique=true)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="label", type="string", length=100, nullable=false)
*/
private $label;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(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-hooks。无法对未安装的组件执行 React 状态更新
推荐阅读
- excel - 如何根据另一个范围内不同单元格的位置和值对一个范围内的特定单元格求和?
- json - 从Json字符串中提取数据并分成多列
- xpages - 为什么文档没有进入编辑模式
- python - Pandas - 将行中的值设置为自身乘以另一个值
- javascript - WP 音频简码和 AJAX
- ibm-cloud-infrastructure - 使用 slcli 在特定 vlan 和子网中创建 VSI
- maven - 使用 SNAPSHOT 依赖项时,Maven 找不到类定义
- python - Python:如果 XML 标记不存在,我需要打印“空白”以及输出
- swift - 如何计算保存的对象数量
- git - 如何通过最新推送找到特定文件名的用户的电子邮件 ID?