Skip to content

Render from database without reload #29

@tingk415

Description

@tingk415

Hi, I watched your awsome video from youtube. I am just trying to reimplement the react version such that the query from database can be executed without clicking the reload button. I tried something below but it doesnt work. It gives the error TypeError: Cannot read properties of undefined (reading 'filter'). Can you please help? Thanks

componentDidMount() {
var that=this
const driver = neo4j.driver("bolt://demo.neo4jlabs.com", neo4j.auth.basic("gameofthrones", "gameofthrones"),{encrypted: true});
const session = driver.session({database:"gameofthrones"});

session
  .run('MATCH (n)-[r:INTERACTS1]->(m) RETURN { id: id(n), label:head(labels(n)), community:n.louvain, caption:n.name, size:n.pagerank } as source, { id: id(m), label:head(labels(m)), community:n.louvain, caption:m.name, size:m.pagerank } as target, {weight:r.weight, type:type(r), community:case when n.community < m.community then n.community else m.community end} as rel LIMIT $limit', {limit: neo4j.int(5000)})
  .then(function (result) {
    const nodes = {}
    const links = result.records.map(r => { 
       var source = r.get('source');source.id = source.id.toNumber();
       nodes[source.id] = source;
       var target = r.get('target');target.id = target.id.toNumber();
       nodes[target.id] = target;
       var rel = r.get('rel'); if (rel.weight) { rel.weight = rel.weight.toNumber(); }
       return Object.assign({source:source.id,target:target.id}, rel);
    });
  that.setState({ data: {nodes, links}, loading: false });
})

}

render() {
return(




)
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions