I'm new in react-redux and I was reading the documentation here https://github.com/reactjs/react-redux/blob/master/docs/api.md
The documentation says that connect
is defined as:
connect([mapStateToProps], [mapDispatchToProps], [mergeProps], [options])
But then I see this example code
import React from 'react'
import { connect } from 'react-redux'
import { getData } from '../actions'
class Content extends React.Component {
constructor(props) {
super(props);
}
componentWillMount() {
this.props.dispatch(getData())
}
render() {
const { data } = this.props; //This data is the same returned for fungetStore
return (
<div>
<h1> { data.text } </h1>
</div>
);
}
}
const fungetStore = store => {
return {
data: store //Return the content of the store
}
}
Content = connect(fungetStore)(Content)
export default Content
You can see in the code that the fungetStore
is sent in connect. But why connect is used in this way? It's not supposed that you must define mapStateToProps
and/or mapDispatchToProps
?. There is something in the documentation that I'm missing out?