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

前端 未结 29 1066
花落未央
花落未央 2020-11-30 00:07

I\'m trying to use react hooks for a simple problem

const [personState,setPersonState] = useState({ DefinedObject });

with following depend

29条回答
  •  醉酒成梦
    2020-11-30 00:54

    I had the same issue, but not with the App. I had a custom class but used a lowercase letter to start the function name and also received the error.

    Changed the first letter of the function name and the export line to CamelCase and error gone.

    in my case the end result was something like:

    function Document() {
    ....
    }
    export default Document;
    

    this solved my problem.

提交回复
热议问题