Created
September 15, 2016 22:34
-
-
Save panw/ef42b2c226d8fa8b30c90ea3702ad211 to your computer and use it in GitHub Desktop.
Revisions
-
panw created this gist
Sep 15, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ class Timeline << React::Component { def initialize(props) { super(props) @state = { tweets: [] } } def component_did_mount() { self.fetchTweets(); } def fetch_tweets() { open('/tweets/recent') do |response| self.setState({tweets: response}) end } def render() { # Assumes JSX exist in Ruby return ( <section> <ul> <% @state.tweets.each do |tweet| %> <Tweet data=<% tweet %> /> <% end %> </ul> </section> ); } }