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

225
Views
React: How to make registrable dynamic nav menu items?

it seems like a dumb question but I didn't find any answer on SO or Google...

I want to make a simple admin panel menu which could expose a method to dynamically add a menu item like so:

function SomeRandomComponent() {

    const targetRoute = `my/route`

    sideMenu.addMenuItem('Link label', targetRoute)

    return <Route path={targetRoute}>
        <div>
            My page
        </div>
    </Route>
}

I didn't manage to find a good way to expose the setState method to other component. And I don't see another solution.

Have you got any clues on how to achieve that please?

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

0

Actually there are many ways to do that but the most elegant is using ContextAPI or useReducer Hook in your app. Then, menu items could be dynamically iterated from the state.

If the app has implemented Redux it's worth to do it there. But don't overkill by implementing Redux exclusively for that thing.

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!