Рендеринг создания и модификации моей формы в администраторе платформы API не работает - PullRequest
0 голосов
/ 05 мая 2020

У меня проблема в админке. Мой api в порядке (могу опубликовать и получить), но когда я хочу создать или обновить объект с помощью панели администратора, у меня есть белая форма: screen

У меня также есть это предупреждение в моей консоли :

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)

Кто-нибудь может мне помочь? заранее спасибо

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

1 Ответ

1 голос
/ 05 мая 2020

Вы не поделились кодом, поэтому трудно быть точным, но вы можете попытаться отслеживать, смонтирован ли ваш компонент или нет.

Ознакомьтесь с этим сообщением в блоге, которое может предоставить дальнейшее (и более подробное) представление об этой проблеме: https://www.debuggr.io/react-update-unmounted-component/

Также может быть принят принятый ответ по этой ссылке быть связанными: React-hooks. Невозможно выполнить обновление состояния React на отключенном компоненте

...