提问者:小点点

我的表单创建和修改渲染在api平台admin不工作


我的管理面板有问题。我的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平台的本机代码。

我的应用程序。js是(REACT\u APP\u API\u入口点=https://localhost:8443):

import React from 'react';
import { HydraAdmin } from '@api-platform/admin';

export default () => <HydraAdmin entrypoint={process.env.REACT_APP_API_ENTRYPOINT}/>;

我的apinelmio_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;
    }
}


共1个答案

匿名用户

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

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

此外,此链接上的公认答案可能也与此相关:React hooks。无法对未安装的组件执行React状态更新