I'm trying to make a search field, and I'm already able to do searches, but it only returns posts that are typed with the same title or are exactly the same which would not be interesting, this happens in my conditional if (query !== post .title && query) return null The ideal would be to search just one word and return similar posts, I've tried using the includes method as follows if (query !== post.title && query.includes(post.title) && query) return null but someone didn't work Would you help me ?
{(() => {
if (isLoading) return <LoadingBlock />
if (!isLoading && postList.length === 0) return <NoDataWarning text='Nenhuma postagem encontrada.' />
return postList.map((post, index) => {
if (query !== post.title && query.includes(post.title) && query) return null //the problem is here
return (
<PostContainer position={index}>
<PostBanner />
<PostInfoContainer>
<span>
<AiFillCalendar />
{new Date(post.createdAt).toLocaleDateString()}
</span>
<span>
<FaUserCircle />
{`${post.firstName} ${post.lastName}`}
</span>
</PostInfoContainer>
<PostTitle>{post.title}</PostTitle>
</PostContainer>
)