close

[Solved] React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function

I am facing the following error: React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function in ReactJS. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Let’s Get Start with This Article.

How React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function Occurs?

I am facing the following error.

React Hook "useState" is called in function "app" which is neither a React function component or a custom React Hook function

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function?

  1. How To Solve React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function?

    To Solve React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function In React there are Rules For React Component. React components need to be capitalized theirs First Latter. For React Custom Hooks These Rules Apply.  React Custom Hooks need to start with use. And Now your error must be solved.

  2. React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function

    To Solve React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function This error Usually Occurs when You are using React Component but Your Component name Starts with the Lower case then You Might face this error. So You Just need To Rename Your Component with UpperCase. For Example, if My React Component Name is an app then My React Component Name Must be Start With Capital Latter Just Like App. Also, Make Sure When Youare Expoering It There also You should Use Upper Case First Latter, and then your error will Be solved. Thanks.

Solution 1: use Capital Latter For React components

This error Usually Occurs when You are using React Component but Your Component name Starts with the Lower case then You Might face this error. So You Just need To Rename Your Component with UpperCase. Just Like below.

const App = props => {...}

export default App;

For Example, if My React Component Name is an app then My React Component Name Must be Start With Capital Latter Just Like App. Also, Make Sure When Youare Expoering It There also You should Use Upper Case First Latter, and then your error will Be solved. Thanks.

Solution 2: Follow The Rules

In React there are Rules For React Component.

  • React components need to be capitalized theirs First Latter

For React Custom Hooks These Rules Apply.

  •  React Custom Hooks need to start with use.

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment