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

HyperReact is a wrapper for the React.js library for making UIs. HyperReact gives all the integrity of React joined with the expressiveness of the Ruby dialect.

Posted by assignment help online at

Thanks for the best blog.it was very useful for me. keep sharing such ideas in the future as well. this was actually what i was looking for,and i am glad to came here!

Posted by Godaddy promo code at

Gratitude for the good blog. It was extremely helpful for me. Remain giving out such thoughts in the prospect as fine. This was really what I was appearing for, and I am joyful to arrive here!

Posted by Research Paper Writing Service Cheap at

I appreciate all the work you put into this site, helping out others with your fun and creative works.

Posted by Hummer H3 2018 at

This is very useful post it helped me alot. great work, keep sharing.

Posted by JENNIFER MORRISON BLACK LEATHER JACKET at

Hey friends now you have the golden chance for you to get the google play gift card which will let you to get all the premium movies,games,videos,images and many more applications from the google play store without paying any amount.

Posted by google play gift card at

Angular.js is very complicated language, here i want to use this comment function in my personal website, i know i need some thing change i should do it according  my website. i really workind Angular Js because its new technology.

Posted by online leather store at

it is good. https://spanish982.wordpress.com/

Posted by Md Amil at

it is good.

Posted by Md Amil at

The GT made a name for itself in the 1960s, and the nameplate returned to Ford for the 2005 and 2006 models. Since then, the vehicle has truly evolved into a supercar, evident by it’s $100,000+ price tag.
The company has made some changes to the third-generation GT, prioritizing handling and track capabilities in their 2017 model. The result? Not only one of Ford’s most impressive cars ever, but perhaps one of the most innovative cars to ever be released.

Posted by 2017 Ford GT Release Date at

Add your comment