我在api平台管理中的表单创建和修改渲染不成功

问题描述 投票:-1回答:2

我的管理面板有一个问题,我的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}/>;

我的nelmio_cors.yaml在我的api中。

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;
    }
}

reactjs symfony api-platform.com
2个回答
1
投票

你没有分享任何代码,所以很难精确,但你可以尝试跟踪你的组件是否被挂载。

查看这篇博客文章,它可以提供关于这个问题的进一步(和更详细)的见解。https:/www.debuggr.ioreact-update-unmounted-component

另外这个链接上的公认答案可能也是相关的。React-hooks。无法在未安装的组件上执行React状态更新。

© www.soinside.com 2019 - 2024. All rights reserved.