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

82
Vistas
Is this right why to edit data?

I,m working on one project and I want to update my data in the below object I use Lodash's _.set method so in the future this below object can be anything but sub-object like Buttons and Content are the same because this thing is needed in website and they are diff for diff template.

"content_navData": {
  "path": ["content", "content_navData"],
  "logo": {
    "path": ["content", "content_navData", "logo"],
    "imgUrl": "https://source.unsplash.com/user/erondu/50x50",
    "settings": {
      "class": ["defaultLogo"]
    }
  },
  "navLinks": {
    "path": ["content", "content_navData", "navLinks"],
    "Home": {
      "path": ["content", "content_navData", "navLinks", "Home"],
      "title": "Home",
      "type": "link",
      "href": "/",
      "setting": {
        "class": ["defaultLink"],
        "isActive": true
      }
    },
    "About": {
      "path": ["content", "content_navData", "navLinks", "About"],
      "title": "About",
      "type": "link",
      "href": "/about",
      "setting": {
        "class": ["defaultLink"],
        "isActive": true
      }
    },
    "Blog": {
      "path": ["content", "content_navData", "navLinks", "Blog"],
      "title": "Blog",
      "type": "link",
      "href": "/blog",
      "setting": {
        "class": ["defaultLink"],
        "isActive": true
      }
    }
  },
  "navButtons": {
    "LogIn": {
      "title": "Log in",
      "type": "button",
      "setting": {
        "class": ["defaultButton", "ghostButton"],
        "isActive": true
      }
    },
    "SignUp": {
      "title": "Sign Up",
      "type": "button",
      "setting": {
        "class": ["defaultButton", "ghostButton"],
        "isActive": true
      }
    }
  }
},

I'm using react and redux for state and data management so I don't want to define the same reducer for diff Template object.

As you can see here I don't want a hardcoded path for reducer so I diced that i us path key in each object that has a proper path for that obj. I this the right way to a big project??

const componentReducer = (state = initialState, action) => {
  switch (action.type) {
    case componentEditType.EDIT_DESCRIPTION:
      return _.set(initialState, ['content', 'hero', 'data', 'description'], action.payload)
  }
}

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