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

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

    In JSX, the lower-case tag name is considered as html native component. In order to react recognise the function as React component, need to Capitalized the name.

    Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the named variable, so if you use the JSX  expression, Foo must be in scope.
    

    https://reactjs.org/docs/jsx-in-depth.html#html-tags-vs.-react-components

提交回复
热议问题