Home > OS >  React useRef working fine but error in production?
React useRef working fine but error in production?

Time:05-01

React Hook "useRef" is called in function "header" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".Screenshot here

CodePudding user response:

This error message is pretty straightforward. If header is a React component, its name should start with a capital letter:

const Header = () => {
  // ...
}

CodePudding user response:

The shown error is not about useRef, you used it inside a wrong named react component header, should be named Header instead alway with an uppercase.

  • Related