My server has code like this:
<ReactRedux.Provider store={store}><Layout defaultStore={JSON.stringify(store.getState())}/></ReactRedux.Provider>
<Layout>
obviously has more components which nest more.
I have a class like this deeper down:
import React from 'react';
export default React.createClass({
render: function(){
var classes = [
'js-select-product',
'pseudo-link'
];
if (this.props.selected) {
classes.push('bold');
}
return (
<li className="js-product-selection">
<span onClick={this.props.onClick} className={classes.join(' ')} data-product={this.props.id}>{this.props.name}</span>
</li>
);
}
});
What I really want to do rather than this.props.onClick
is dispatch an event to set state in a reducer. I've been some things online about context but I've gotten mixed reviews as that feature was or wasn't going away.
EDIT
I see this connect method but I could have sworn I'd read not to use connect
in children components.