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

240
Visualizações
TypeError: react_1.useEffect is not a function

I am trying to make us of useEffect in my React component but I am encountering an issue with the following error:

TypeError: react_1.useEffect is not a function

and

Uncaught (in promise) TypeError: react_1.useState is not a function

I have imported the libraries like this

import React, { useEffect } from 'react'

and have the useEffect like this:

useEffect(() => {
  console.log("This is cool")
}, [intentButton])

The react version is 16.7.0

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

this is because the react V16.7 does not have hooks

The resolution is to downgrade to

   npm i react@next react-dom@next 

which as of 2018/12/20 is 16.7.0-alpha.2:

yarn add react@next react-dom@next

then lose the test renderer:

 import React from 'react'
 import ReactDOM from 'react-dom'
 import App from './App'
 it('renders without crashing', () => {
    const div = document.createElement('div')
    ReactDOM.render(<App />, div)
    ReactDOM.unmountComponentAtNode(div)
 })

This is what package.json should be:

  "react": "^16.7.0-alpha.2",
  "react-dom": "^16.7.0-alpha.2",
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