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

228
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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