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

86
Views
multiple-drawer reactJs in same page not working

I am intern ReactJs, how to use multiple-drawer reactJs in same page.
code my App.js file

    App = () =>{
    const [visible, setVisible] = useState(false);
    const showDrawer = () => {
        setVisible(true);
    };
    const onClose = () => {
        setVisible(false);
    };
    return(
    // drawer 1
    <Button type="primary" className="btn-submit" onClick={this.showDrawer}>submit drawer 1</Button>
     <Drawer className="modal-form"onClose={onClose} visible={visible}>
         content
    </Drawer>
    // drawer 2
    <Button type="primary" className="btn-submit" onClick={this.showDrawer}>submit drawer 2</Button>
    <Drawer className="modal-form"onClose={onClose} visible={visible}>
         content
    </Drawer>
    )
   }

how can i click on the button tag to show the corresponding drawer! pls! help me.

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

0

If these drawers contain different content then you will have to manage two state variables for each drawer to control the visibility of drawer.

App = () =>{
    const [visibleDrawer1, setVisibleDrawer1] = useState(false);
    const [visibleDrawer2, setVisibleDrawer2] = useState(false);
    const showDrawer1 = () => {
        setVisibleDrawer1(true);
    };
    const onCloseDrawer1 = () => {
        setVisibleDrawer1(false);
    };
    const showDrawer2 = () => {
        setVisibleDrawer2(true);
    };
    const onCloseDrawer2 = () => {
        setVisibleDrawer2(false);
    };
    return(
    // drawer 1
    <Button type="primary" className="btn-submit" 
      onClick={this.showDrawer1}>submit drawer 1</Button>
     <Drawer className="modal-form"onClose={onCloseDrawer1} 
      visible={visibleDrawer1}>
         content
    </Drawer>
    // drawer 2
    <Button type="primary" className="btn-submit" 
     onClick={this.showDrawer2}>submit drawer 2</Button>
    <Drawer className="modal-form"onClose={onCloseDrawer2} 
       visible={visibleDrawer2}>
         content
    </Drawer>
    )
   }
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!