Permalink
Browse files

Including React.addons. Refactoring 'Record' addRecord and deleteReco…

…rd methods
  • Loading branch information...
fervisa committed May 18, 2015
1 parent 1a4dc64 commit d19127f40ae2f795a30b7de6470cde95d3734eee
Showing with 5 additions and 5 deletions.
  1. +3 −5 app/assets/javascripts/components/records.js.coffee
  2. +2 −0 config/application.rb
@@ -21,14 +21,12 @@
@debits() + @credits()
addRecord: (record) ->
- records = @state.records.slice()
- records.push record
+ records = React.addons.update(@state.records, { $push: [record] })
@setState records: records
deleteRecord: (record) ->
- records = @state.records.slice()
- index = records.indexOf record
- records.splice index, 1
+ index = @state.records.indexOf record
+ records = React.addons.update(@state.records, { $splice: [[index, 1]] })
@replaceState records: records
render: ->
View
@@ -22,5 +22,7 @@ class Application < Rails::Application
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
+
+ config.react.addons = true
end
end

0 comments on commit d19127f

Please sign in to comment.