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

174
Views
setIsOpen is not a function

I'm creating a modal in react, I want that when a card is clicked the modal comes up but I'm having an issue showing it. I'm using UseState to handle the opening and closing (toggle true or false), but when clicking on the card, I'm getting an error that says TypeError: setIsOpen is not a function How can I make it work? I don't understand why this is happening. this is my code.

import React, { useState } from "react";
import Modal from "../modal/projectModal.jsx";

// Scss
import "./projectBox.scss";

const ProjectBox = (props) => {
  const { isOpen, setIsOpen } = useState(false);

  return (
    <div>
      <div className="portfolio__box" onClick={() => setIsOpen(true)}>
        <img src={props.preview} alt="project" />
        <div className="portfolio__hover-info flex-center">
          <div className="text-center">
            <p className="font30 weight800">{props.title}</p>
            <p className="font12 weight500">{props.tag}</p>
          </div>
        </div>
      </div>
      <Modal open={isOpen}>project details</Modal>
    </div>
  );
};

export default ProjectBox;

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change { } to [ ] in your useState.
So, it would be like

const [ isOpen, setIsOpen ] = useState(false);
about 4 years ago · Juan Pablo Isaza Report
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!