Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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 answers
Answer question

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 Report

0

Fixed the issue, I had multiple Reactjs running

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!