I am trying to understand how to get the props to show up when exporting a functional component like this
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
The normal method works as it should
functionaName.propTypes = { // propTypes here }
const mapStateToProps = state => ({ // state stuff here })
const mapDispatchToProps = { // props mapping here }
export default connect(mapStateToProps, mapDispatchToProps)(functionName);
I am trying to organize my imports and have a folder structure like so
components
item // contains the component
index.jsx
index.js
index.js
export * from './item';
Then doing an import would be like this
import { functionName } from '../components';
My actual code does have a return value, I just truncated it for this post. Any ideas on how to accomplish what I am looking to achieve?
For this code to work:
You need your
components/index.js
too look like this:Here are some examples from one of my projects: