From 3c29f5740447270a4122b334281a907ecbdd4165 Mon Sep 17 00:00:00 2001 From: kibigo! Date: Tue, 26 Dec 2017 16:54:28 -0800 Subject: WIP Refactor; ed. --- app/javascript/flavours/glitch/util/redux_helpers.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/javascript/flavours/glitch/util/redux_helpers.js') diff --git a/app/javascript/flavours/glitch/util/redux_helpers.js b/app/javascript/flavours/glitch/util/redux_helpers.js index 3bc8bc86f..c0f5eeb28 100644 --- a/app/javascript/flavours/glitch/util/redux_helpers.js +++ b/app/javascript/flavours/glitch/util/redux_helpers.js @@ -1,3 +1,6 @@ +import { injectIntl } from 'react-intl'; +import { connect } from 'react-redux'; + // Merges react-redux props. export function mergeProps (stateProps, dispatchProps, ownProps) { Object.assign({}, ownProps, { @@ -5,3 +8,9 @@ export function mergeProps (stateProps, dispatchProps, ownProps) { state: Object.assign({}, stateProps, ownProps.state || {}), }); } + +// Connects a component. +export function wrap (Component, mapStateToProps, mapDispatchToProps, options) { + const withIntl = typeof options === 'object' ? options.withIntl : !!options; + return (withIntl ? injectIntl : i => i)(connect(mapStateToProps, mapDispatchToProps, mergeProps)(Component)); +} -- cgit