This repository was archived by the owner on Sep 15, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed
Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import React, { PropTypes } from 'react'
33export class Terms extends React . Component {
44
55 static propTypes = {
6- terms : PropTypes . arrayOf ( PropTypes . array ) . isRequired
6+ terms : PropTypes . arrayOf ( PropTypes . object ) . isRequired
77 }
88 static defaultProps = {
99 terms : [ ]
@@ -22,13 +22,12 @@ export class Terms extends React.Component {
2222
2323 componentWillMount ( ) {
2424 this . shuffleArray ( this . props . terms )
25- console . log ( this . props . terms )
2625 }
2726
2827 render ( ) {
2928 return ( < div className = '' >
3029 < div className = 'text-center' >
31- { this . props . terms . map ( ( term ) => < p key = { term [ 0 ] } > { term [ 0 ] } </ p > ) }
30+ { this . props . terms . map ( ( term ) => < p key = { term . word } > { term . word } </ p > ) }
3231 </ div >
3332 </ div > )
3433 }
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ export const getTopTerms = (tweets: Array): Array => {
3434 let count = counts . get ( word ) || 0
3535 counts . set ( word , count + 1 )
3636 } )
37- // Sort words by counts
38- let ret = Array . from ( counts . entries ( ) )
39- ret . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] )
37+ // Sort words by counts, descending
38+ let ret = Array . from ( counts . entries ( ) ) . map ( ( [ word , count ] ) => ( { word , count } ) )
39+ ret . sort ( ( a , b ) => b . count - a . count )
4040 // Return only top 10 terms
4141 ret = ret . slice ( 0 , 10 )
4242 return ret
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export class TwitterView extends React.Component {
2323 getTweets : PropTypes . func . isRequired ,
2424 tweets : PropTypes . arrayOf ( PropTypes . string ) . isRequired ,
2525 screenName : PropTypes . string ,
26- topTerms : PropTypes . arrayOf ( PropTypes . array ) . isRequired
26+ topTerms : PropTypes . arrayOf ( PropTypes . object ) . isRequired
2727 }
2828
2929 componentWillMount ( ) {
You can’t perform that action at this time.
0 commit comments