-1

I have a problem in my admin panel. My api is ok, (can post and get) but when i want create or update object with admin panel, I have a white form: screen

I have also this warning in my console :

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)

Somebody can help me ? thank you in advance

I have not changed the native code of api platform.

my app.js is (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}/>;

My nelmio_cors.yaml in my 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

An exemple of an entity in 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;
    }
}

Corentin
  • 1
  • 1

1 Answers1

1

You did not share any code so it is hard to be precise but you can try keeping track of whether your component is mounted or not.

Check out this blog post, which can provide further (and more detailed) insight about this issue: https://www.debuggr.io/react-update-unmounted-component/

Also the accepted answer on this link might also be related: React-hooks. Can't perform a React state update on an unmounted component

reincore
  • 345
  • 5
  • 11