• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

143
Views
'useState is not a function' React deploy showing nothing

I have tried to deploy a basic React App (still v. early in the works). The page breaks on load- shows nothing but the background, and I have an error in the console '.useState is not a function'

Below is the component that is flagged up in the issue. And here is the link to the open sourced code: https://github.com/mariaalouisaa/3-in-1-react

Thank you in advance!!

import "./Home.css";
import home from "./images/home.png";
import TimeAndDate from "./TimeAndDate";
import Todo from "./Todo";
import Stopwatch from "./Stopwatch";
import { useState } from "react/cjs/react.development";

export default function Home() {
  const [dateVis, setsetDatevis] = useState(false);
  const [todoVis, setsetTodovis] = useState(false);
  const [stopVis, setsetStopvis] = useState(false);

  function popUp(e) {
    if (e.target.name === "date") setsetDatevis(true);
    if (e.target.name === "todo") setsetTodovis(true);
    if (e.target.name === "stop") setsetStopvis(true);
  }

  return (
    <div>
      <button
        onClick={() => {
          setsetDatevis(false);
          setsetTodovis(false);
          setsetStopvis(false);
        }}
        className="homebutton"
      >
        <img src={home} alt={home} />
      </button>
      <div className="Home">
        <button name="date" onClick={popUp}>
          Time + Date
        </button>
        <button name="todo" onClick={popUp}>
          To-do {<br />}List
        </button>
        <button name="stop" onClick={popUp}>
          Stop- watch
        </button>
        <TimeAndDate active={dateVis} />
        <Todo active={todoVis} />
        <Stopwatch active={stopVis} />
      </div>
    </div>
  );
}

This is the error message

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

0

I think you should import React too and import useState in correct way as it said in documentation:

import React, { useState } from 'react';
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error