34 lines
783 B
JavaScript
34 lines
783 B
JavaScript
|
import React, { Component } from 'react';
|
||
|
import { Link } from 'react-router-dom';
|
||
|
import { connect } from 'react-redux';
|
||
|
import testAction from '../actions/test';
|
||
|
|
||
|
class Home extends React.Component {
|
||
|
clickBtn() {
|
||
|
this.props.testAction('some new value');
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<div>
|
||
|
This is home. { this.props.test }
|
||
|
<div>
|
||
|
<Link to="/topics">Go to topics</Link>
|
||
|
</div>
|
||
|
<div>
|
||
|
<button onClick={ this.clickBtn.bind(this) }>Click me</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const mapStateToProps = state => ({
|
||
|
test: state.home.test
|
||
|
});
|
||
|
|
||
|
const mapDispatchToProps = dispatch => ({
|
||
|
testAction: value => dispatch(testAction(value))
|
||
|
});
|
||
|
|
||
|
export default connect(mapStateToProps, mapDispatchToProps)(Home);
|