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

141
Visualizações
Invalid Hook Call use-neo4j

I recently started building a react app. I wanted to configure a neo4j database attached to the application. I decided to use the use-neo4j hook. I followed the basic step of creating the driver instance like this:

import React from "react";
import ReactDOM from "react-dom";
import "./css/index.css";
import App from "./js/App";
import Nav from "./js/Nav";
import { Neo4jProvider, createDriver } from "use-neo4j";

const driver = createDriver("neo4j", "localhost", 7687, "lode", "neo4j");

ReactDOM.render(
  <React.StrictMode>
    <Neo4jProvider driver={driver}>
      <Nav />
      <App />
    </Neo4jProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

But I ended up having the Invalid Hook Call error. Except if I remove the Neo4jProvider tags Seen in this image here enter image description here

I tried everything I can to fix it, I'm pretty new at React. I would love someone to help me if they can.

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

0

Just like the error says, you can only call hooks inside the body of a functional component. So I would probably create a component that initiates the driver and returns the component that uses it -

import { Neo4jProvider, createDriver } from "use-neo4j";

const NeoProvider = ({ children }) => {
  const driver = createDriver("neo4j", "localhost", 7687, "lode", "neo4j");

  return (
    <Neo4jProvider driver={driver}>
      {children}
    </Neo4jProvider>
  );
}

And then import that at your top level and use that instead of the Neo4jProvider you're importing from the package.

about 4 years ago · Juan Pablo Isaza Relatório

0

Fixed the issue, I had multiple Reactjs running

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