Hey there, Am working on a react.js project and am stuck with this error

Please can someone help me with this error? I had tried so many tricks, but the error keeps occurring again. below is a screenshot and the code.

const mapStateProps = ({state, ownProps}) => ({ collection: selectCollection(ownProps.match.params.collectionId) (state)
});

I’ve edited your post for readability. I do not know what you are trying to do; there was very little I could do to clean up the function. Please review it, and edit to add exactly what you have.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

1 Like

Do you understand that the error is saying that ownProps is undefined?

Therefore, we need to see where you call the function, and with what arguments.

No, I don’t I thought the error is the match this is the code so far.

import React from 'react';
import { connect } from 'react-redux';

import CollectionItem from '../../components/collection-item/collection-item';
import { selectCollection } from '../../redux/shop/shop.selectors.js';

import './collection.styles.scss';

const CollectionPage = ({ collection }) =>{
    const { title, items } = collection;
return(
    <div className='collection-page'>
        <h2 className='title'>{ title }</h2>
        <div className='items'>
            {
             items.map(item => (
                <CollectionItem key={item.id} item={item}/>

            ))}
        </div>
    </div>
)};

const mapStateProps = ({state, ownProps}) => ({
    collection: selectCollection(ownProps.match.params.collectionId)(state)
});

export default connect(mapStateProps)(CollectionPage);

Unfortunately, my experience with Redux stops at the fCC curriculum. So, I can point you to these two lessons:

  1. Connecting Redux to React
  2. Connecting Redux to App

Lastly, the only thing I can think that is the issue is the fact that the mapStateProps function is probably only being called with an object of one parameter (being state), but you have it defined as accepting an object with two parameters.

Hope this helps

1 Like

yea sure, thanks a lot for your time and also the link you provided for me, I’ll check them out. I truly appreciated.