It’s just data

React.rb

Having determined that Angular.js is overkill for my blog rewrite, I started looking more closely at React.  It occurred to me that I could do better than JSX, so I wrote a Ruby2JS filter.  Compare for yourself.  Excerpt from the React tutorial:

var CommentList = React.createClass({
  render: function() {
    var commentNodes = this.props.data.map(function (comment) {
      return (
        <Comment author={comment.author}>
          {comment.text}
        </Comment>
      );
    });
    return (
      <div className="commentList">
        {commentNodes}
      </div>
    );
  }
});

Equivalent using the Ruby2JS filter:

class CommentList < React 
  def render
    _div.commentList do
      @@data.forEach do |comment|
        _CommentBlock comment.text, author: comment.author
      end
    end
  end
end

Note: I renamed the Comment class to CommentBlock to avoid a conflict with the existing Comment API.  I wouldn’t have thought that would be necessary, but things didn’t work until I made this change.

Full source for the tutorial reimplemented in Ruby is available.


Problem with Comment has been fixed.  Underlying cause was ruby2js attempting to us an ES6 feature: const.

Posted by Sam Ruby at

Its really great article i have seen today, I appreciated your hard work and experience. I would love to share your article to other platforms. Thanks for sharing!

Posted by Harley Davidson Leather Jacket at

Call Girls in Faridabad
Female Escorts in Faridabad
Russian Escorts in Faridabad
Call Girls in Agra
Escorts Service in Agra
Female Escorts in Agra
Russian Escorts in Agra
Female Escorts in Faridabad
Escorts in Faridabad
Call Girls in Faridabad
Escorts Service in Faridabad
Escorts in Faridabad
Female Escorts in Faridabad
Russian Escorts in Faridabad
Call Girls in Agra
Escorts Service in Agra
Female Escorts in Agra
Russian Escorts in Agra
Female Escorts in Faridabad
Call Girls in Faridabad
Escorts Service in Faridabad
Escorts in Faridabad
Female Escorts in Faridabad
Russian Escorts in Faridabad
Call Girls in Agra
Escorts Service in Agra

Posted by Pooja Ahuja at

Try using hash tags. That way your blog gets put out there when people are searching for certain.

Posted by Apoc Yellow Jacket at

ReactComponent life cycle, the native this will be passed to the class’s initializer. And all corresponding life cycle methods (componentDidMount, etc) will be invoked on the instance using the snake-case method name.

Posted by mcdvoice at

I have been wondering about this issue, so thanks for posting.

Pest Control in Henderson

Posted by Pest Control in Henderson at

Great post really. It helps me a lot. Thanks for sharing this.

Posted by Programming Assignment Help at

Try using hash tags

Posted by Toko Bunga Jakarta at

Time For Try This Tutorial

Posted by Kios Komputer at

I love it! We are following your website posts. 
Please keep on posting and sharing great ideas.
Posts are all wonderful.

Best Home Renovations Kitchener

Posted by Best Home Renovations Kitchener at

Thanks for Your article..it gives us immense knowledge.Body massage gives you ultimate relief to your body.i would like to recommend each and everyone go for massage once in a week for ultimate relief. it will not only gives you relief but also increase your productivity.

escorts near me

call girls near me

Jaipur call girls

Jaipur Escort

Posted by Jaipur call girls at

Students who wish to score A+ grade in such typical assignments can connect to us at www.essaycorp.com and avail the excellent assignment help in structural engineering. EssayCorp currently offering flat 10% discount on each assignment booking. We assure 100% plagiarism free assignments without any error. Acquire our swift assistance and submit your assignment before the deadline. Hurry up and avail the benefits now!

Posted by John Smith at

There are many writing companies functioning in the market, but despite their presence, these companies have never maintained a loyal clientele because of their poor working strategies. Unlike them, Essays Tigers is renowned for providing quality writing assistance to students. So, choose the best UK essay writing service for assistance by placing an order now!

Posted by Best essay help online at

Thanks blogger for sharing the best article.

Posted by Peaky Blinders Coat at

Add your comment