Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

93
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda