Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Last active April 20, 2016 10:34
Show Gist options
  • Save StevenLangbroek/0a7e33ec11b82ca927a7373b21767fdb to your computer and use it in GitHub Desktop.
Save StevenLangbroek/0a7e33ec11b82ca927a7373b21767fdb to your computer and use it in GitHub Desktop.
Rather than decorators, docs recommend this pattern.
import React from 'react';
import { connect } from 'react-redux';
import ProductBody from 'components/ProductBody';
// Export named for testing
export const Product = ({
product
}) => (
<div className="product">
<h1>{product.get('title')}</h1>
<ProductBody product={product} />
</div>
);
const mapStateToProps = (state, props) => ({
product: state.getIn(['entities', 'products', props.params.productId])
});
// Export "decorated" for implementation
export default connect(mapStateToProps)(Product);
import React from 'react';
import { Product } from 'components/Product'; // By importing the named component you don't have to deal with store availability.
// etc. etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment