ReactJS
ReactJS
constants/ActionTypes.js
export const RESET_PURCHASE = 'RESET_PURCHASE';
actions/purchase.js
import { RESET_PURCHASE } from 'constants/ActionTypes';
...
function resetPurchase () {
return { type: RESET_PURCHASE };
}
reducers/purchase.js
import { Map } from 'immutable';
import { RESET_PURCHASE } from 'constants/ActionTypes';
const defaultPurchase = Map({
loaded: false,
selectedPaymentOption: '',
nationalityCountries: []
});
export function purchase (state = defaultPurchase, action) {
switch (action.type) {
case RESET_PURCHASE: { return defaultPurchase; }
}
}
export default purchase;
components/purchase/Purchase.js
import Checkout from 'containers/purchase/Checkout';
import React from 'react';
import PropTypes from 'prop-types';
import SomeContainer from 'containers/SomeContainer';
const propTypes = {
}
containers/purchase/Purchase.js
import { connect } from 'react-redux';
import { reset, formValueSelector } from 'redux-form';
import { someFunction } from 'actions/purchase';
import { PurchaseComponent } from 'components/purchase/Purchase';
...