'useSelector returns undefined on console.log

the code

const Question = () => {

    const idd = useSelector(state => state.idd)
    const questions = useSelector(state => state.questions)
    console.log(questions)

    console.log(idd)
    return(
     <>
     </>
    )
}
const mapStateToProps = ({ authedUser, questions, users }, { id }) => {
    const idd = id
    console.log(idd)

    return {
        authedUser,
        questions,
        users,
        idd
    }
}

the result of console.log(questions) print questions


the result of console.log(idd) is udefined can you help me please?



Solution 1:[1]

i just get it from props directly by adding props to Component=(props) and console.log(props.id)

Solution 2:[2]

It doesn't look like something named "idd" was ever part of your Redux store? In that case, yes, it is completely normal to get undefined here - useSelector only gives you access to your Redux store.

useSelector has nothing to do with mapStateToProps (that just maps state to props, as the name implies) and you should not use useSelector and connect/mapStateToProps together and prefer useSelector whenever possible.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nassim
Solution 2