Good afternoon friends, I introduce myself to this community, I have a question I hope you can clarify,
How do I show the initial status of the store in react-redux ?
I have a simple component with a <h1>
in react , which I will place a onClick
so that when I click on it I change that title for another, in the store I have the initial state text:"titulo"
; How do I display this title on the <h1>
tag that I have in react ?
Here the component code:
import React from 'react'
import {connect} from 'react-redux'
class TodoApp extends React.Component {
render() {
return(
<div>
<h1 onClick={this.cambio}> {this.props.text} </h1>
</div>
)
}
}
const mapStateToProps = state => {
return {
text: state.text
}
}
const mapDispatchToProps = dispatch => {
return {
cambio(text) {
dispatch({
type: "CAMBIAR",
text:"se cambio"
})
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)