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

114
Vistas
Can we use a function inside a selector in react js

I have recently got stucked at a place where I want to call a function that is accessing the store values inside a selector.

So the scenario is something like this, inside a selector I'm having some initial values but during a particular functionality I want to update the selector response with some extra attributes which I'm getting from a function. So that, at the end I got the initial values with some modifications, is it possible and how should we approach the problem?

Will be providing code snippet of the selector, function

In the selectOngoingFee selector I want to call constructData function and for a special condition I need the selector to manipulate the returnObj. I couldn't show you the exact implementation, actually I was stuck at the very first step so if I get to know how I can I call constructData and pass store in that will be very helpful.

selectAccountFeeRate is another selector which gives the result as {
  aofValue: {
    pensionFee: {
      amount: '7',
      type: 'AOF',
      taxIncluded: 'NO'
    }
  }
}

const constructData = (store, accountNumber) => {
  const pensionSavingAOF = selectAccountFeeRate(state, accountNumber) || {}
  const pensionSavingData = {
    fees: [{
      feeType: 'AOF',
      value: pensionSavingAOF.aofValue.pensionFee.amount,
      isVatIncluded: pensionSavingAOF.aofValue.pensionFee.taxIncluded === YES

    }]
  }
  return {
    pensionSaving: pensionSavingData
  }
}

const selectOngoingFee = createSelector([selectRetrievedQuoteDetails], (quoteDetails)) => {
  const {
    ongoingFee
  } = quoteDetails || {}
  const pensionSaving = {
    fees: []
  }
  if (!isEmpty(ongoingFee)) {
    ongoingFee.forEach((item) => {
      const data = {
        feeType: 'AOF',
        value: item.amount,
        isVatIncluded: item.taxIncluded
      }
      if (item.accountType === 'PENSION_SAVING_ACCOUNT') {
        pensionSaving.fees.push(data)
      }
    })
  }
  const returnObj = {
    ...(pensionSaving.fees.length ? {
      pensionSaving
    } : {})
  }
  return returnObj
}

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Although I have asked this question but after reading a lot of data. I came to know that the only way is to create another function, pass the constructData and select OngoingFee as arguments and manipulate it. Hope my understanding is correct here.

about 4 years ago · Santiago Trujillo 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