Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I've been using rails' erb template for my views, but I've recently been trying to incorporate React as my front end framework. I'm a little lost on how front end frameworks are supposed to be used.

e.g. Using React to render a static button

var AddProspects = React.createClass({  
  displayName : 'AddProspects',
  render: function() {
    return (
        <button type="button" className="btn btn-info pull-right btn-block" data-toggle="modal" data-target="#uploadModal">
            <i className="fa fa-plus"></i> Upload Prospects
        </button>
    );
  }
});

React.render(<AddProspects />, document.getElementById("#add-prospects"));

e.g. Using normal html

<button type="button" class="btn btn-info pull-right btn-block" data-toggle="modal" data-target="#uploadModal">
  <i className="fa fa-plus"></i> Upload Prospects
</button>

Using React in this example seems to be a overkill.

Should I be using React for the whole view? Should React be rendering everything from static html to dynamic data from the server side? Or is it better to use it just for elements that interact with the server and leave static stuff to plain html?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

React is focused on using plain html.

That is why you can just type HTML tags inside your react code. The idea is to keep it simple.

Simple answer is: Yes, you should write a lot of plain HTML. When you need to program some piece to use it inside React, then define it on ReactJS. I believe a greate rule of thumb is: When in doubt, think what will be messier (Harder to maintain the code later), and do things the other way. :D

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.