I\'m trying to use react hooks for a simple problem
const [personState,setPersonState] = useState({ DefinedObject });
with following depend
React components (both functional as well as class) must begin with a capital letter. Like
const App=(props)=>Hey
class App extends React.Component{
render(){
return Hey
}
}
React identifies user-defined components by following this semantic. React's JSX transpiles to React.createElement function which returns an object representation of the dom node. The type property of this object tells whether it is a user-defined component or a dom element like div. Therefore it is important to follow this semantics
Since useState hook can only be used inside the functional component(or a custom hook) this is the reason why you are getting the error because react is not able to identify it as a user-defined component in the first place.
useState can also be used inside the custom hooks which is used for the reusability and the abstraction of logic. So according to the rules of hooks, the name of a custom hook must begin with a "use" prefix and must be in a camelCase