How to use React-Bootstrap in react.rb

183 views Asked by At

I'm using react.rb in my project, And I want to use bootstrap too. I found the React-Bootstrap,but don't know how to use it in react.rb.

2

There are 2 answers

0
贾延平 On

Thanks to @catmando share the answer.

First, define a wrapper:

class RB < React::NativeLibrary
  imports ReactBootstrap
end 

Then, using it like this

RB.Button(bs_style: :default){"My Button"}
0
BarrieH On

There is a new way of doing this, simply add require 'reactrb/auto-import' to components.rb then all JS libraries that are required will be automatically imported into the Ruby namespace so after that you can access the JS components directly. See an example here: https://github.com/barriehadfield/reactrb-showcase#working-with-react-bootstrap