import React, { Component } from 'react';
import { fetchData } from '../../actions/fetchData';
import { loader } from '../loader/loader';
import { connect } from 'react-redux'
class App extends Component {
render(){
this.props.getFetchData()
return (
<div className="App">
{this.props.data}
</div>
);
}
}
const mapStateToProps = state => {
return {
name: this.state && this.state.name
}
}
const mapDispatchToProps = dispatch => {
return {
getFetchData: () => {
dispatch(fetchData())
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(App);
В чем может быть причина?
const mapStateToProps = state => { // принимаем аргумент
return {
name: state && state.name, // используем аргумент
};
};
const mapStateToProps = state => ({
name: state && state.name,
});