我无法测试这个简单的react容器。记录对我没有帮助...
import React, {Component} from 'react'
import {connect} from 'react-redux'
import {loadBoards} from '../../actions/boardJS'
import Board from '../../components/Board/Board'
class BoardContainer extends Component {
getBoards() {
fetch(process.env.REACT_APP_DEV_API_URL + `todo_lists`)
.then(res => res.json())
.then(data => {
this.props.dispatch(loadBoards(data))
})
}
componentDidMount() {
this.getBoards()
}
render() {
return <Board/>
}
}
const mapStateToProps = state => {
return {
boards: state.boards
}
}
export default connect(mapStateToProps)(BoardContainer)
如何测试mapStateToProps或componentDidMount?我需要简单的工作示例。谢谢!