I'm trying to use something like a contains()
function in redux but apparently it doesn't exist.
case types.FILTER_MESSAGES_BY_CONTENT:
return {
...state,
messageSearchResults: state.messages.map(message => message.content.contains(action.search))
};
Action:
export function filterMessagesByContent(search) {
return {
type: types.FILTER_MESSAGES_BY_CONTENT,
search: search
};
}
Console.log of messages returns me this (one of them):
0:
category: "posuere"
comments: (4) [{…}, {…}, {…}, {…}]
content: "Quisque id justo sit amet sapien dignissim vestibulum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla dapibus dolor vel est. Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros."
date: "2018-09-07 08:12:18"
downVotes: 15
id: 2
upVotes: 6
__proto__: Object
In this case messages has all messages and in messageSearchResults
I want to put every message that contains the search query I'm giving.
How would I do this?