-4
Good evening, I performed a CRUD project with Node, React and Mysql, but when trying to create routes in front-end, is generating the error:
React Hook "useState" is called in Function "Register" that is neither a React Function Component nor a custom React Hook Function. React Component Names must start with an uppercase Letter. [! [insert a description of the image here][1]][1]
As verified in the error, I tried to change the "useState" for "Usestate" (initial uppercase letter), but thus changing the function property.
import React, { useState } from "react"
import './style.css';
import Axios from 'axios'
function register() {
const [nomeReg, setNomeReg] = useState('')
const [dateReg, setDateReg] = useState('')
const [cpfReg, setCpfReg] = useState('')
const [emailReg, setEmailReg] = useState('')
const [senhaReg, setSenhaReg] = useState('')
When the code was a single route it was working correctly.
When compiling the React:
src\pages\register.js
Line 6:35: React Hook "useState" is called in function "register" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter react-hooks/rules-of-hooks
Line 7:35: React Hook "useState" is called in function "register" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter react-hooks/rules-of-hooks
Line 8:33: React Hook "useState" is called in function "register" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter react-hooks/rules-of-hooks
Line 9:37: React Hook "useState" is called in function "register" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter react-hooks/rules-of-hooks
Line 10:37: React Hook "useState" is called in function "register" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter react-hooks/rules-of-hooks
Search for the keywords to learn more about each error.
Welcome to [en.so]! You have posted an image of the code and/or error message. Although it sounds like a good idea, it’s not! One of the reasons is that if someone wants to answer the question, they can’t copy the code and change something inside. Click on the [Edit] link and put the code/error as text. See more about this in these links - Manual on how NOT to ask questions, Post Error Message as Picture
– Augusto Vasques
This answers your question? Why React does not accept camelCase to name components?
– Rafael Tavares