Created
June 21, 2015 01:33
-
-
Save karmajunkie/8dd5367837ee8d2bd5bd to your computer and use it in GitHub Desktop.
Doing React all wrong...
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
var ScheduleStore = Reflux.createStore({ | |
init(){ | |
this.listenToMany(ScheduleActions); | |
}, | |
schedule(){ | |
return this._schedule; | |
}, | |
setSchedule(schedule){ | |
this._schedule = schedule; | |
} | |
//... other store logic | |
} |
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
var Scheduler = React.createClass({ | |
mixins: [Reflux.connect(ScheduleStore, 'schedule')], | |
getInitialState(){ | |
return {schedule: ScheduleStore.schedule()}; | |
}, | |
render(){ | |
//... | |
} | |
}); |
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
=content_for :javascript do | |
javascript: | |
ScheduleStore.setSchedule(JSON.parse('#{ schedule.to_json.html_safe}')); | |
h1 Schedule | |
= react_component("Scheduler") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment