reactjs / react-rails

Integrate React.js with Rails views and controllers, the asset pipeline, or webpacker.
Apache License 2.0
6.74k stars 757 forks source link

when i'm use JSX and bootstrap (menu etc), js from bootstrap dont apply #541

Closed eduscrakozabrus closed 8 years ago

eduscrakozabrus commented 8 years ago

Help us help you! Please choose one:


when i'm use JSX and bootstrap (menu etc), js from bootstrap dont apply (Describe your issue here)

rmosolgo commented 8 years ago

Hi, could you share some details about your situation? for example:

Thanks!

eduscrakozabrus commented 8 years ago

home.js.jsx

var Home = React.createClass({
  propTypes: {
    data: React.PropTypes.string
  },

  render: function() {
    return (
      <div>
        <div>Name of portal: {this.props.data}</div>
          <div class="btn-group" role="group" aria-label="...">
    <button type="button" class="btn btn-default">Left</button>
    <button type="button" class="btn btn-default">Middle</button>
    <button type="button" class="btn btn-default">Right</button>
  </div>
      </div>
    );
  }
});

/view/home/index.html.erb

<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>

<%= react_component( 'Home', {data: 'Корпоративный портал'}) %>

2016-05-30 11 29 11

gem file

gem 'react-rails'

gem 'therubyracer'
gem 'less-rails' # Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem 'twitter-bootstrap-rails'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.0.0.rc1', '< 5.1'
# Use sqlite3 as the database for Active Record

application.js

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require turbolinks
//= require react
//= require react_ujs
//= require components
//= require_tree .

2016-05-30 11 31 16

eduscrakozabrus commented 8 years ago

and result :( ....

2016-05-30 11 29 11

rmosolgo commented 8 years ago

Use className in JSX, don't use class! (https://facebook.github.io/react/docs/jsx-in-depth.html#html-tags-vs.-react-components) Does that fix it?

(I see that bootstrap's CSS is loaded because the font is Helvetica.)

eduscrakozabrus commented 8 years ago

Yes. This is in className my error, Snx!

rmosolgo commented 8 years ago

Cool, glad we found it!