Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
can someone tell me why this error appears to me?

The error :

React Hook "useState" is called in function "createFlight" 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

My code:

import React, {Component} from 'react';
import { useState } from 'react'




function createFlight(){
    const [flight, setflight] = useState({flightNumber: "", departureTime: "", arrivalTime: "", departureDate: "", arrivalDate: "", cabin: "", economySeatsAvailable: "", businessSeatsAvailable: "", airport: "", from: "", to: "" });
    
}

export default createFlight;
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Change the name of your component to start with an uppercase (as the error states).

function CreateFlight(){

If instead it is supposed to be a custom hook you need to name it prepending use in the name. Such as useCreateFlight

about 4 years ago · Juan Pablo Isaza Relatório

0

React hooks can only be called in React components or other React hooks.

React components have to be upper-case, like so

function CreateFlight(){
    const [flight, setflight] = useState();
}

They can then be rendered like so

<CreateFlight />

React hooks are functions that bind behaviour into a component. They have to be named "use..." like, "useFlight" or something.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda