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

112
Views
Accordiaon - Randering menu list in react component

I am trying to render folowing menu item dynamicly based on category but Stuck it is not rendering properly. It it rather giving me error or rendering just item unable to filter through category

    export default const Menu =[
    {
    id: 120,
    name: "Johnnie Walker ",
    category: "SPIRITS",
    price: "$8 per 30ml",
    description:
      "Black Label",
    },
    {
    id: 125,
    name: "Johnnie Walker (Gold Label)",
    category: "Drinks",
    price: "$12 per 30ml",
    description:
      "Johnnie Walker (Gold Label)",
    },
    {
    id: 122,
 
    name: "Smirnoff Vodka",
    category: "SPIRITS",
    price: "$9 per 30ml",
    description:
      "Vodka ",
    },]

    import React, { useState } from 'react';
    import Menu from './Menu';
    import styled from 'styled-components';
    import { IconContext } from 'react-icons';
    import { FiPlus, FiMinus } from 'react-icons/fi';    
    const AccordionMenu = () => {

    const [items, setItems] = useState(Menu);
    const [clicked, setClicked] = useState(false);

    const filterItem = (categItem) => {
      const updatedItems = Menu.filter((curElem) => {
          return curElem.category === categItem;
      });
      setItems(updatedItems);
     
    }


    const toggle = index => {
      if (clicked === index) {
        //if clicked question is already active, then close it
        return setClicked(null);
      }
  
      setClicked(index);
    };
    
     <IconContext.Provider value={{ color: '#00FFB9', size: '25px' }}>
     <AccordionSection>
      <Container>
        {Data.map((item, index) => {
          return (
            <>
              <Wrap onClick={() => toggle(index)} key={index}>
                <h1 onClick={() => filterItem()}>{data.category}</h1>
                <span>{clicked === index ? <FiMinus /> : <FiPlus />}</span>
              </Wrap>
              {clicked === index ? (
                <Dropdown>
                  <p>{item.name}</p>
                  <p>{item.description}</p>
                  <p>{item.price}</p>
                </Dropdown>
              ) : null}
            </>
          );
        })}
       </Container>
      </AccordionSection>
      </IconContext.Provider>
    );
   };

Hi, I am trying to render folowing menu item dynamicly based on category but Stuck it is not rendering properly. It it rather giving me error or rendering just item unable to filter through category

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!