我正在尝试在我的Redux应用程序中将Dispatch和State发送到我的演示组件的道具但我不断收到标题中所述的错误。
我的演示组件如下所示: 的 ./组件/ AutoFillList.js
import React, { PropTypes } from 'react'
const AutoFillList = ({ songTitle, songLink, onClick }) => (
<a href={songLink}>
<li onClick={onClick}>{songTitle}</li>
</a>
)
AutoFillList.propTypes = {
onClick: PropTypes.func.isRequired,
songTitle: PropTypes.string.isRequired,
songLink: PropTypes.string.isRequired
}
export default AutoFillList
我的Container组件如下所示: ./ containers / AutoFillLogic.js
import React from 'react'
import { connect } from 'react-redux'
import AutoFillList from '../components/AutoFillList'
const mapStateToProps = (state) => {
return{
songTitle: state.songTitle,
songLink: state.songLink
}
}
const mapDispatchToProps = (dispatch) => {
return{
onClick: () => {return}
}
}
const AutoFillLogic= connect(mapStateToProps, mapDispatchToProps)(AutoFillList)
export default AutoFillLogic
解决方案:按照Florent的建议,在App.js中渲染智能组件而不是哑组件。所以在这种情况下,它意味着渲染&#34; AutoFillLogic&#34;而不是&#34;自动填充列表&#34;