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

205
Vistas
reactjs : overlay onHide doesn't work even if the rootClose added

Below is my code.However,when I click the place outside of the overlay,the overlay doesn't disappear.But I do add the rootClose and onHide as you can see in the code.I would be grateful if anyone could help.

import React, { useRef, useState } from "react";
import Overlay from 'react-overlays/Overlay'

function Overlayhtml () {
  return (
    <div>overlay works!</div>
  )
}

export function OverlayTest () {

  const btnRef = useRef()
  const containerRef = useRef()
  const [show, setShow] = useState(false)

  const handleClick = () => {
    setShow(!show)
  }

  const handleHide = () => {
    setShow(false)
  }

  return (
    <div ref={containerRef}>
      <button ref={btnRef} onClick={handleClick}>btn</button>
      <Overlay show={show} placement='bottom' target={btnRef.current} container={containerRef.current} rootClose={true} onHide={handleHide}>
        {() => <Overlayhtml />}
      </Overlay>
    </div>
  )
}

about 4 years ago · Juan Pablo Isaza
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