[Solved] Undefined but in array [closed]


action.postId returns an object, not a string:

console.log(action.postId)
> { postId: 'BAcyDyQwcXX' }

As-is, you either need to use action.postId.postId to get the key, or unwrap action.postId so it contains the string, not object.

console.log(state[action.postId.postId]);
> Array(4)

action.postId = 'BAcyDyQwcXX';
console.log(state[action.postId]);
> Array(4)

solved Undefined but in array [closed]