Skip to content

Commit 86442f9

Browse files
authored
Update README.md
1 parent 96f1246 commit 86442f9

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,66 @@ Start your Rails server ```rails s``` and navigate to ```localhost:3000/api/v1/m
250250
<a href="http://tinypic.com?ref=2m60ahx" target="_blank"><img src="http://i63.tinypic.com/2m60ahx.png" width="450" height="450" border="0" alt="Image and video hosting by TinyPic"></a>
251251

252252
Congrats! You have successfully created a Rails API and completed your first GET request!
253+
254+
## Downloading React into our Project
255+
256+
React is a component based front end framework that makes it easy to make frontend calls to our Rails API. Let's make this organized as possible and add our react directory inside our rails app.
257+
258+
1. Open your terminal and create a new project inside your API.
259+
```
260+
create-react-app client
261+
```
262+
<br>
263+
<a href="http://tinypic.com?ref=1zya22t" target="_blank"><img src="http://i64.tinypic.com/358xiu0.png" border="0" height="300" width="280" alt="Image and video hosting by TinyPic"></a>
264+
<br>
265+
266+
2. Download Boostrap into the react directory:
267+
268+
```
269+
npm install --save reactstrap bootstrap@4
270+
```
271+
272+
Then open your ```index.js``` file inside the ```/src``` directory and add the following import line:
273+
```javascript
274+
import React from 'react';
275+
import ReactDOM from 'react-dom';
276+
import './index.css';
277+
import App from './App';
278+
import * as serviceWorker from './serviceWorker';
279+
// Import goes below for Bootstrap
280+
import 'bootstrap/dist/css/bootstrap.css';
281+
```
282+
283+
3. We'll make a default Component directory inside the ```/src``` folder and create our first component.
284+
285+
```
286+
cd client/src && mkdir components && cd components && touch Button.js
287+
```
288+
4. Open your ```Button.js``` file and lets create a sample button to active our call function to the API.
289+
290+
```javascript
291+
import React, { Component } from 'react';
292+
293+
class Button extends Component {
294+
render() {
295+
return (
296+
<div>
297+
<div class="card container mt-3">
298+
<div class="card-body">
299+
<div class="row">
300+
<center>
301+
<button class="btn btn-primary">Test Call!</button>
302+
</center>
303+
</div>
304+
</div>
305+
</div>
306+
</div>
307+
);
308+
}
309+
}
310+
311+
export default Button;
312+
313+
```
314+
315+
5. Start your server `npm start` and check if your bootstrap import works as well as the test button!

0 commit comments

Comments
 (0)