score:1

function Projects() {
  const [isOpen, setIsOpen] = useState('nothing');

  return (
    <Wrapper>
      {data.projects.map((proj, index) => (
        <ProjectContainer background={proj.image} 
          onClick={()=>setIsOpen(oldIndex => index === isOpen ? 'nothing' : index)}>
          {isOpen === index && (
            <Popup project={proj.name} description={proj.description} />
          )}
        </ProjectContainer>
      ))}
    </Wrapper>
  );
}

Related Query

More Query from same tag