repertoire
  • Repertoire.js
  • Using Repertoire
  • API Reference
    • Controller
    • dispatchActions
  • Help
  • Changelog
Powered by GitBook
On this page
  1. API Reference

dispatchActions

PreviousControllerNextHelp

Last updated 6 years ago

The dispatchActions utility can be used to manually connect the Redux store state or dispatch actions to a component which is not directly linked to a controller, by using the utility.

import React, {Component} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {dispatchActions} from 'repertoire'

class User extends Component {
  render() {
    return <div />;
  } 
}

const mapStateToProps = state => ({
  users: state.admin.users
});

const mapDispatchToProps = dispatch => bindActionCreators({
  setCurrentUser: dispatchActions.setCurrentUser
}, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(User);
  
connect()