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

296
Views
React, trigger one modal to open when another closes

I'm working on implementing a modal which can open another modal. I have a user sign up modal which has a "Add Contact" button. Clicking this button triggers the "Add Contact Modal" to appear.

AddContactModal is an older component and is currently called in the App.js file right above the main Routes component.

<Router forceRefresh={!supportsHistory()}>
   <div className={appClassNames}>
     <Providers>
       <AddContactModal />
       <PhoneVerificationModal />
       <NavBar currentUser={this.state.currentUser} />
       <div className="app-content">
           {Routes(actions)}
           <Footer />
       </div>
   </Providers>
 </div>
</Router>

The Routes(actions) renders most of the application. AddContactModal also has all of its functions declared in a global context file so it can be opened from anywhere in the application.

My new modal SignUpModal lives on a particular route and has all of its functions in a local hooks folder.

-src
--context
----addContactModalContext.js
--scenes
----Contacts
-------addContactModal.js
----SignUp
------signUpHooks.js
------signUpModal.js

Because of the structure used I can call the function to open my contact modal from my signup modal. However I cannot reopen the signup modal from the contact modal.

I have tried adding event listeners to the signup page to listen for the contact modal submit and I was not successfully.

I know I could restructure things but that would be a pretty large endeavor.

Hoping someone has some advice. Ideally submitting the contact modal would trigger the sign up modal to open again ONLY when the user is on the sign up page.

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

0

Maybe handle some state for your submit in your context, so it can be heard with an useEffect in your other component and it handles showing up the modal you need. Not sure if it would help but maybe it's a new idea.

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!