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

167
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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