【发布时间】:2021-01-15 07:18:19
【问题描述】:
我正在尝试了解如何在导出这样的功能组件时显示道具
export const functionName = ({...props}) => {
console.log(props); // undefined
return <p>Hello</p>
}
functionaName.propTypes = { // propTypes here }
const mapStateToProps = state => ({ // state stuff here })
const mapDispatchToProps = { // props mapping here }
export default connect(mapStateToProps, mapDispatchToProps)(functionName); // works like it should
正常的方法可以正常工作
functionaName.propTypes = { // propTypes here }
const mapStateToProps = state => ({ // state stuff here })
const mapDispatchToProps = { // props mapping here }
export default connect(mapStateToProps, mapDispatchToProps)(functionName);
我正在尝试组织我的导入并拥有这样的文件夹结构
components
item // contains the component
index.jsx
index.js
index.js
export * from './item';
然后做一个导入会是这样的
import { functionName } from '../components';
我的实际代码确实有一个返回值,我只是为这篇文章截断了它。关于如何实现我想要实现的任何想法?
【问题讨论】:
标签: reactjs react-redux react-functional-component