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

a href="hhttp://www.govtjobcorner.com/himachal-pradesh-pat-admit-card///">Himachal Pradesh PAT Admit Card 2018 | HP PAT Exam Date</a> :wow this articlso amezing. i m so impress.

Posted by HRITIK at

Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. Cincinnati Ohio

Posted by BachJohann at

by visiting this site I found cool stuff here keep it up.

Posted by CS Assignment Help at

This is really great work. Thank you for sharing such a good and useful information here in the blog for students.

Posted by Online Programming Homework Help at

Students could often find it tough to write their academic tasks. It could lead to they not getting desired grades in the academics. Opting for our assignment help online could be ideal for such students and they can get a complete assignment solution from us. https://www.allassignmenthelp.com

Posted by assignment help online at

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. florida map

Posted by BachJohann at

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. healthfama

Posted by BachJohann at

دانلود قسمت چهارم فصل سوم سریال شهرزاد با لینک مستقیم, دانلود رایگان کامل قسمت 4 چهار فصل 3 سریال شهرزاد با لینک مستقیم راحت اسان کم حجم کیفیت بالا عالی, قسمت چهار 4 فصل سه 3 شهرزاد با لینک مستقیم سریال ایرانی جدید ساخته حسن فتحی بدون تگ آرم تبلیغاتی نیاز به خرید اشتراک ویژه با لینک مستقیم دانلود شهرزاد قسمت چهارم

Posted by BachJohann at

really appreciate this wonderful post that you have provided for us. thank u so much

Posted by Kerala HSC Date Sheet at

I really appreciate the post. It is very informative.

Posted by Quality hub at

I really appreciate the post. It is very informative.

Posted by Bonnie murithi at

I really enjoyed reading your post. very informative blog and very exciting to know more on this topic.

Posted by My Assignment Help at

The government of Tamil Nadu releases their results on their official websites, but the higher authority does not yet announce the

official website of publishing the results,

Posted by SSLC Result 2018 Tamilnadu at

This is very nice information share with me

Posted by website development company in delhi at

I am an antique article collector and this article is one of the best I have ever read. I hope to see the same amazing work from you in future. Thanks Marketing Assignment help

Posted by Assignment Help at

Very helpful advice in this particular post! It’s the little changes that make the largest changes. Thanks for sharing!

Posted by impossible game at

It Is Very Interesting post. Thanks for share.

Posted by Dry Cleaners Point at

I havent any word to value this post.....Really i am inspired from this post....the individual who make this post it was an extraordinary human..thanks for imparted this to us. Chinese Gender Predictor

Posted by BachJohann at

Add your comment