Created
June 1, 2020 12:54
-
-
Save sumit-gupta91/06a8ad3c09866fcde18885c02d21a33a to your computer and use it in GitHub Desktop.
A way to reduce complexity while exporting a component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bindActionCreators, compose } from 'redux'; | |
const mapStoreToProps = data => ({ | |
[createVendorPayoutFields.EXISTING_VENDOR]: | |
data[createVendorPayoutFields.EXISTING_VENDOR], | |
[createVendorPayoutFields.CREATED_VENDOR]: | |
data[createVendorPayoutFields.CREATED_VENDOR], | |
[createVendorPayoutFields.VENDOR_STEP_STATE]: | |
data[createVendorPayoutFields.VENDOR_STEP_STATE], | |
[createVendorPayoutFields.INTERNAL_NOTES]: | |
data[createVendorPayoutFields.INTERNAL_NOTES], | |
[createVendorPayoutFields.INVOICE_NUMBER]: | |
data[createVendorPayoutFields.INVOICE_NUMBER], | |
[createVendorPayoutFields.FUND_ACCOUNT]: | |
data[createVendorPayoutFields.FUND_ACCOUNT], | |
[createVendorPayoutFields.TOTAL_AMOUNT]: | |
data[createVendorPayoutFields.TOTAL_AMOUNT], | |
[createVendorPayoutFields.SUB_TOTAL]: | |
data[createVendorPayoutFields.SUB_TOTAL], | |
[createVendorPayoutFields.INVOICE_ISSUE_DATE]: | |
data[createVendorPayoutFields.INVOICE_ISSUE_DATE], | |
[createVendorPayoutFields.DUE_DATE]: data[createVendorPayoutFields.DUE_DATE], | |
[createVendorPayoutFields.DESCRIPTION]: | |
data[createVendorPayoutFields.DESCRIPTION], | |
[createVendorPayoutFields.TDS_CATEGORY]: | |
data[createVendorPayoutFields.TDS_CATEGORY], | |
[createVendorPayoutFields.INVOICE_ID]: | |
data[createVendorPayoutFields.INVOICE_ID], | |
}); | |
const mapDispatchToProps = (dispatch) => ({ | |
showErrorNotification: bindActionCreators(showErrorNotification, dispatch), | |
}); | |
export default compose( | |
connect(mapStateToProps, mapDispatchToProps), | |
withWizardStep, | |
)(ReviewStep) |
@prabhasjoshi this is a gist which tells the overall idea, if an HOC needs to be called with an argument call it with and argument, if it does not do not call it with arguments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Sumit,
Yes this works,
A small suggestion-
in this section
It should be