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

306
Visualizações
What's causing this error when using react-bootstrap's OverlayTrigger and Popover components?

I've copied and modified a react-bootstrap Popover from the examples provided here, but it's not yet working properly. The button renders correctly, but when I click it to display the popover, I get an error saying "Element type is invalid: expected a string [...] or a class/function [...] but got: undefined. You likely forgot to export your component [...]".

Can anyone see what's causing this issue?

import {Button, OverlayTrigger, Popover} from "react-bootstrap";
// ...
renderColumnOptionsButton() {
  return (
    <OverlayTrigger
      trigger="click"
      placement="left"
      overlay={
        <Popover>
          <Popover.Header as="h3">
            Choose which columns to display:
          </Popover.Header>
          <Popover.Body>
            options will go here
          </Popover.Body>
        </Popover>
      }
    >
      <Button variant="secondary">Column Options</Button>
    </OverlayTrigger>
  );
}
// ...
render() {
  // ...
    {this.props.allowColumnSelection &&
      {this.renderColumnOptionsButton()}
    }
  // ...
}

Thanks in advance for your help!

EDIT:

I removed the Popover element from the overlay prop and replaced it with <text>hello</text>, and the overlay worked just fine. This means the issue is definitely coming from handing the Popover element to the OverlayTrigger.

I realized that the Popover requires an id prop, but when I provide one the tag gets underlined by WebStorm and tells me Type JSX.element is not assignable to type PropTypes.Requireable[...].

I tried removing the Popover and placing it in a const, both with const popover = (...) and const popover = () => (...), along with <OverlayTrigger ... overlay={popover}> and neither of those work either, but they don't give that WebStorm tooltip on the id prop anymore. I still have it set up with the latter form, and currently the line overlay={popover} is underlined and WebStorm again tells me Type function is not assignable to type PropTypes.Requireable[...].

I'm doing it just like in the examples, but the overlay prop of OverlayTrigger seems to not like anything I give to it. What am I doing wrong?

EDIT 2:

I figured out the issue! I'm actually using react-bootstrap v4 and instead of <Popover.Header> and <Popover.Body>, it uses <Popover.Title> and <Popover.Content>. Swapping those out fixed the issue.

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