Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!