import * as logins from './../constants/login';
export const loginRequested = ():any => ({
type: logins.LOGIN_REQUESTED
})
export const loginSuccess = (payload:any) => ({
type: logins.LOGIN_SUCCESS,
payload
})
export const loginFailed = (payload:any) => ({
type: logins.LOGIN_FAILED,
payload
})
import { Dispatch } from 'redux';
import * as actions from './../actions/login';
export const login = (payload: any) => (dispatch:any) => {
dispatch(actions.loginRequested());
}
import React, {useState } from 'react';
import { connect } from 'react-redux';
import {login} from './../../middlewares/thunks';
const Login = (props:any) => {
}
....................
const mapStateToProps = (state: any) => ({
authenticated: state.app.isAuthenticated
})
const dispatchToProps = {
login
}
export default connect(mapStateToProps, dispatchToProps)(Login);
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Products from './../components/Products';
import Product from './../components/Product';
import PropTypes from 'prop-types';
import {actAddToCart, actChangeMessage} from './../actions/index';
class ProductsContainer extends Component {
}
.................................
var mapDispatchToProps = (dispatch, props) => {
return {
onAddToCart : (product) => {
dispatch(actAddToCart(product,1))
},
onChangeMessage: (message) => {
dispatch(actChangeMessage(message));
}
}
};
export default connect(mapStateToProps, mapDispatchToProps)(ProductsContainer);