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

139
Views
¿Es posible abrir una vista previa de imagen antd con un botón?

Quiero abrir la vista previa de una imagen en antd sin hacer clic en la miniatura de la imagen (por ejemplo, haciendo clic en un botón):

 import React from 'react'; import {Image, Button} from 'antd'; const Foo: React.Fc<any> = (props) => { const [isPreviewVisible,setPreviewVisible] = useState<boolean>(false); return ( <div> <Image // something like this // isPreviewVisible={isPreviewVisible} src="some url" /> <Button onClick={()=>setState(!isPreviewVisible)}>Click me!</Button> </div> ); };

Me gustaría implementarlo de manera similar al código anterior, pero no pude encontrar ninguna forma de hacerlo.

Editar: quiero controlar/alternar la visibilidad de la vista previa con un estado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes hacerlo así:

 function ImageDemo() { const [isPreviewVisible, setPreviewVisible] = useState(false); return ( <> <Image width={200} preview={{ visible: isPreviewVisible, onVisibleChange: (visible, prevVisible) => setPreviewVisible(visible), }} src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" /> <Button onClick={() => setPreviewVisible(!isPreviewVisible)}> Click me </Button> </> ); }

También he implementado un ejemplo aquí , puedes comprobarlo:

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