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

190
Visualizações
Styled component not generating styles on new windows

I'm having a hard time trying to make react-select render a dropdown on a new windows. I figured there was some issues with styled components and I found this GitHub issue with a solution to my exact problem: https://github.com/styled-components/styled-components/issues/3274

But it's not working yet. Can someone help me understand how to render the react-select dropdown correctly on a new window?

Here's my code:

// app.tsx

import "./styles.css";

import React, { useState } from "react";

import SelectComponent from "./control";

export default function App() {
  const [show, setShow] = useState(false);

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <a onClick={() => setShow(!show)}>Click me</a>
      {show && <SelectComponent show={show} />}
      <div style={{ marginTop: "50px" }}>Status: {show ? "True" : "False"}</div>
    </div>
  );
}

And the other file is:

// control.tsx

import React, { useState, useRef } from "react";
import Select from "react-select";
import styled, { StyleSheetManager } from "styled-components";
import Popout from "react-popout";

const options = [
  { value: "chocolate", label: "My Chocolates" },
  { value: "strawberry", label: "Strawberry" },
  { value: "vanilla", label: "Vanilla" }
];

const SelectComponent = ({ show }) => {
  const nwRef = useRef();

  return (
    <StyleSheetManager target={nwRef.current}>
      <div ref={nwRef}>
        <Popout isPopout={true}>
          <Select
            options={options}
            // menuPortalTarget={nwRef.current}
            styles={{ menuPortal: (base) => ({ ...base, zIndex: 9999 }) }}
          />
        </Popout>
      </div>
    </StyleSheetManager>
  );
};

export default SelectComponent;

Can someone point me in the right direction to render that dropdown correctly? I even tried react-select's menuPortalTarget but it isn't working. Any help would be appreciated.

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