Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating 'AmountBox' component. Adding indicator boxes
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@AmountBox = React.createClass | ||
render: -> | ||
React.DOM.div | ||
className: 'col-md-4' | ||
React.DOM.div | ||
className: "panel panel-#{ @props.type }" | ||
React.DOM.div | ||
className: 'panel-heading' | ||
@props.text | ||
React.DOM.div | ||
className: 'panel-body' | ||
amountFormat(@props.amount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 comments
on commit 8d6f0a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwgoh, those lines are correct. The author is wrapping the callback in parenthesis which aren't necessary but reads better. In Coffeescript, method parens are optional, so the alternative would be
credits: ->
credits = @state.records.filter (val) -> val.amount >= 0
credits.reduce (prev, curr) ->
prev + parseFloat(curr.amount)
, 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philmill I see. Thank you!
In this line of code, as well as follows and the next section,
@state.records
is notArray
butObject
.So in my browser, something went wrong here, which means
filter()
andslice()
function cannot run.