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

168
Vistas
How to use mapStateToProps inside another action?

As I'm new to redux can someone help me if it is possible to make a change in one action based on the state change from different another file.

actions.js

export function setChangeNotification(changeNotification: boolean) {
return {
    type: SET_CHANGE_NOTIFICATION,
    changeNotification
};
}

Toolbar.js

endMeetingForAll () {
    const { _changeNotification } = this.props;
    this.props.dispatch(setChangeNotification(true)); //changed value set to true but at default it's false in my initial state.
    console.log(_changeNotification,'changeNotification from end meeting'); //Checked if value changed using mapStateToProps. 
}
function _mapStateToProps(state) {
    return {
    _changeNotification: Boolean(state['features/toolbox'].changeNotification)
};
}
export default translate(connect(_mapStateToProps)(Toolbox));

Another action.js where I need to make a change

export function notifyKickedOut(participant: Object, _: ?Function) { // eslint-disable-line 
no-unused-vars
return (dispatch: Dispatch<any>, getState: Function) => {
    const args = {
        participantDisplayName:
            getParticipantDisplayName(getState, participant.getId())
    };
    dispatch(showNotification({
        appearance: NOTIFICATION_TYPE.ERROR,
        hideErrorSupportLink: true,
        descriptionKey: 'dialog.kickMessage',
        descriptionArguments: args,
        titleKey: 'dialog.kickTitle',
        titleArguments: args
    }));
    //JAAM CODE
    // when the paticipant removed after redirect to the website.
    setTimeout(
        () => {
            window.APP.conference.hangup(false);
            executeCommand('hangup');
            window.close();
        },
        NOTIFICATION_TIMEOUT);
};
}

In the above action.js I need to dispatch another shownotification if setChangeNotification is true like

  if(changeNotification){
    dispatch(showNotification({
        appearance: NOTIFICATION_TYPE.ERROR,
        descriptionKey: 'dialog.changed',
        titleKey: 'dialog.changed'
    })); 
   }else{
   dispatch(showNotification({
        appearance: NOTIFICATION_TYPE.ERROR,
        hideErrorSupportLink: true,
        descriptionKey: 'dialog.kickMessage',
        descriptionArguments: args,
        titleKey: 'dialog.kickTitle',
        titleArguments: args
    }));

}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have access to the state via calling getState(). Since this looks like a thunk (async action creator) you can dispatch any action you'd like there.

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