From 5b15f67b52b2b5f7d79d6e7d4c7af3f6de45f2a0 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 2 Nov 2017 12:53:41 -0700 Subject: [PATCH] graph listens directly for the presence of vertices --- src/components/graph/graph.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/graph/graph.js b/src/components/graph/graph.js index b8d99597..afe3d124 100644 --- a/src/components/graph/graph.js +++ b/src/components/graph/graph.js @@ -3,7 +3,16 @@ import _ from "lodash"; import styles from "./graph.css"; import {setupGraphElements, drawGraph} from "./drawGraph"; import SectionHeader from "../framework/sectionHeader"; +import { connect } from "react-redux"; +@connect((state) => { + + const vertices = state.cells.cells && state.cells.cells.data.graph ? state.cells.cells.data.graph : null; + + return { + vertices + } +}) class Graph extends React.Component { constructor(props) { @@ -16,15 +25,16 @@ class Graph extends React.Component { } componentWillReceiveProps(nextProps) { + console.log('le grpah', nextProps) /* maybe should do a check here to confirm ref exists and pass it? */ if ( - nextProps.vertices && - nextProps.expressions && - nextProps.expressionsCountsMap && - this.state.context + this.state.context && + nextProps.vertices + // nextProps.expressions && + // nextProps.expressionsCountsMap && ) { drawGraph( - nextProps.vertices.data, + nextProps.vertices, this.state.context, nextProps.expressionsCountsMap );