Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!