Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
Can't put a useRef on the Ant Design drop-down menu button (React Typescript)

I'm using a dropdown list from UI Framework Ant Design, I need to put useRef on it to control it, add or remove Visible={true} attribute. TypeScript gives me this error.

Type '{ children: Element; ref: MutableRefObject; className: string; overlay: Element; trigger: "click"[]; }' cannot be assigned to type 'IntrinsicAttributes & DropDownProps & { children? ReactNode; }'. The 'ref' property does not exist for the type 'IntrinsicAttributes & DropDownProps & { children? ReactNode; }'.

Below are two screenshots, Dropdown Button element and TS error

enter image description here

enter image description here

UPDATE**

My temporary solution looks like this, if I'm on the home page my drop down list is open, if I'm on other pages it opens after a click. But it would be better if through Ref, you could set or remove the attribute visible={true} enter image description here

source code link https://github.com/grigoryanhrant/my-app/blob/master/src/components/Header/index.tsx

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

React components do not have a ref prop by default, only base elements like <div> and <span> etc. do. In order for a React component to pass through a ref prop, you must use React.forwardRef().

It looks like the antd "Dropdown" component does not utilize React.forwardRef(), so you are screwed in this case. Of course, you could check their contribution guidelines and explore submitting an update to their codebase to implement this...

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda