react-use-precision-timer icon indicating copy to clipboard operation
react-use-precision-timer copied to clipboard

Invalid hook call

Open HuangHam opened this issue 6 months ago • 0 comments

Hi! I am trying to use this package and I am following the doc:

import React, { useState, useEffect, useRef, useCallback} from "react";
import { useDelay } from 'react-use-precision-timer';
import styles from ".././index.css";
import { usePlayer} from "@empirica/core/player/classic/react";

export function Fixation({is_practice = false}) {
  const callback = useCallback(() => console.log('Boom'), []);
  // Will call once after 1000ms.
  const onceTimer = useDelay(1000, callback);

However I get this warning:

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

and error:

TypeError: Cannot read properties of null (reading 'useState')

I don't think the react versions are a problem:

npm ls react dyat_v3@ /Users/hh7792/Desktop/Dyat/dyat_v3 └─┬ [email protected] ├─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └── [email protected] deduped └── [email protected]

Anyone has any thoughts on what is going on?

HuangHam avatar Aug 22 '24 03:08 HuangHam