From 0dae0c995fe0b79778512f2226e69422b2a0f6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Thu, 10 May 2018 15:31:20 -0700 Subject: [PATCH] Factor out the non-recursive RecursiveTable Test plan: Behavior is unchanged; manually verify. Paired with @wchargin --- src/app/credExplorer/pagerankTable.js | 40 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/app/credExplorer/pagerankTable.js b/src/app/credExplorer/pagerankTable.js index 3e9b9c8..e11eee3 100644 --- a/src/app/credExplorer/pagerankTable.js +++ b/src/app/credExplorer/pagerankTable.js @@ -4,6 +4,7 @@ import React from "react"; import stringify from "json-stable-stringify"; import {Graph} from "../../core/graph"; +import type {Address} from "../../core/address"; import {PLUGIN_NAME as GITHUB_PLUGIN_NAME} from "../../plugins/github/pluginName"; import {GIT_PLUGIN_NAME} from "../../plugins/git/types"; import {nodeDescription as githubNodeDescription} from "../../plugins/github/render"; @@ -134,18 +135,37 @@ export class PagerankTable extends React.Component { - {nodesByScore.map((node) => { - const score = pagerankResult.get(node.address).probability; - return ( - - {(score * 100).toPrecision(3)} - {Math.log(score).toPrecision(3)} - {nodeDescription(graph, node.address)} - - ); - })} + {nodesByScore.map((node) => ( + + ))} ); } } + +type RTState = {}; +type RTProps = {| + +address: Address, + +graph: Graph, + +pagerankResult: PagerankResult, +|}; + +class RecursiveTable extends React.Component { + render() { + const {address, graph, pagerankResult} = this.props; + const score = pagerankResult.get(address).probability; + return ( + + {(score * 100).toPrecision(3)} + {Math.log(score).toPrecision(3)} + {nodeDescription(graph, address)} + + ); + } +}