Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

320
Visualizações
Dynamic content in Ionic React modal/bottom-sheet causes modals to render on top of eachother

When passing dynamic content to an ion modal bottom sheet, instead of updating the content in the bottom sheet a new bottom sheet is rendered on top of the previous one, eventually leading to a load of modals on top of each other.

I think this is an ion modal issue and not specifically bottom sheet.

The content is updated when a user navigates to a new url path so it may be a navigation issue or to do with the content updating. Either way you can continue to add modals seemingly infinitely even though the ModalDrawer component below is only called once which isn't the expected behaviour.

Here is the code:

import React from 'react';
import { IonModal } from '@ionic/react';
import DrawerContent from '../DrawerContent';
import { useLocation } from 'react-router';

interface PageProps {
  isOpen: boolean;
  isMobile: boolean;
  selectedLocation: any;
  emissionsData: {id: string, name: string, emissions: string[]}[];
  entitiesByBusinessType: object[];
}

const MobileDrawer: React.FC<PageProps> = (props) => {

  const location = useLocation()

  const modalSubject = props.entitiesByBusinessType  || location.pathname === props.emissionsData[0].id ? (
    <DrawerContent 
      entitiesByBusinessType={props.entitiesByBusinessType}
      emissionsData={props.emissionsData}
      isOpen={props.isOpen}
      isMobile={props.isMobile}
    />
  ) : null

  return (
    <div>
      <IonModal 
        isOpen={true}
        swipeToClose={true}
        breakpoints={[ 0.05, 0.4, 0.95 ]}
        initialBreakpoint={0.4}
        backdropBreakpoint={0.4}
        className="bottom-sheet"
        showBackdrop={true}
        backdropDismiss={false}
        children={modalSubject}
      />
    </div>
  );
};

export default MobileDrawer;

Here are some images to further explain my point:

How the app should act (1 bottom sheet): Normal app behaviour

App with multiple bottom sheets/modals on top of each other: App with 2 stacked modals App with 3 stacked modals

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda