Reputation: 405
I have Redux state:
import phones from "./../API/phone.json"
const initialState = {
data: phones
};
I have component and it's containter componenet:
const Iphone = ({phones}) => {
const filterIphone = phones.map((p, index) =>
(<div className="model" key={index}>
<NavLink to={'/CurrentIphone/' + phones.id}>{p.body.model}</NavLink>
</div>
))
return (
<div>
{filterIphone}
</div>
);
};
export default Iphone;
export class CurrentIphoneContainer extends React.Component {
render() {
return (
<CurrentIphone {...this.props} />
)
}
}
const mapStateToProps = (state) => ({
phones: state.phoneReducer.data
})
export default compose(connect(mapStateToProps, {getPhones})(CurrentIphoneContainer))
So the problem is in this string:
<NavLink to={'/CurrentIphone/' + phones.id}>{p.body.model}</NavLink>
My id is undefined, although when I put id to 'p.body.id' It shows. (When i use debugger id brings with props)
Upvotes: 1
Views: 127
Reputation: 405
<NavLink to={'/CurrentIphone/' + p.id}>{p.body.model}</NavLink>
Upvotes: 3