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

前端 未结 29 1017
花落未央
花落未央 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:32

    Whenever working with a React functional component, always keep the first letter of the name of the component in Uppercase in order to avoid these React Hooks errors.

    In your case, you have named the component app, which should be changed to App, as I said above, to avoid the React Hook error.

提交回复
热议问题