Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
Open menu in an array

So im trying to open a menu but the problem is where I am showing the postMenu comp (Posts.js) is an array. So when I show the menu it shows up in all the posts

Posts.comp.js (Where im displaying the postMenu)

  const dispatch = useDispatch();

  const { isLoading, posts, ownerInfo, postsMenuIsOpen } = useSelector(
    (state) => state.posts
  );

// other code...

{posts &&
        posts.map(({ textfield, image, ownerId }) => (
          <div className="px-3 pt-2 pb-1 border border-gray-100 m-1">
            <PostsMenu />
            {ownerInfo &&
              ownerInfo.map(({ _id, displayname, username, profilePic }) => (
                <div>
// html code...

PostsMenu.comp.js (Where the code of menu is)

import React from "react";
import { useSelector } from "react-redux";

function PostsMenu() {
  const { postsMenuIsOpen } = useSelector((state) => state.posts);

  return (
    <div
      className={
        postsMenuIsOpen ? `absolute w-[70%] bg-red-500 z-50` : `hidden`
      }
    >
      PostsMenu
    </div>
  );
}

export default PostsMenu;

Please do let me know if you need more info.

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!