Skip to content

Commit e4b56e8

Browse files
authored
Change order of steps
`Start your server 'npm start' and check if your bootstrap import works as well as the test button! If all is displaying then we are almost done. We are sooooo close!` - button is not displayed since the `Button` component isn't imported and used in `App.js` yet. It feels more natural to first have button implemented and then work on the API call.
1 parent a1a118f commit e4b56e8

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

README.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,30 @@ class Button extends Component {
368368

369369
export default Button;
370370
```
371+
6. Let's open our ```App.js``` file in the /src directory to add our new Button Component to the App itself. Check below to see the example. Don't forget that we need to enclose the ```<Button />``` in two ```<div></div>``` tags!
372+
```javascript
373+
import React, { Component } from 'react';
374+
import logo from './logo.svg';
375+
import './App.css';
376+
377+
import Button from './components/Button';
378+
379+
class App extends Component {
380+
render() {
381+
return (
382+
<div>
383+
<Button />
384+
</div>
385+
);
386+
}
387+
}
371388

372-
6. Start your server `npm start` and check if your bootstrap import works as well as the test button! If all is displaying then we are almost done. We are sooooo close!
389+
export default App;
390+
```
373391
374-
We want our button to actually call the API now so lets create the function with the appropriate call. We want to add an onclick event to the button html like so:
392+
Start your server `npm start` and check if your bootstrap import works as well as the test button! If all is displaying then we are almost done. We are sooooo close!
393+
394+
7. We want our button to actually call the API now so lets create the function with the appropriate call. We want to add an onclick event to the button html like so:
375395
376396
```javascript
377397
<button class="btn btn-primary" onClick={this.callApi}>
@@ -449,28 +469,6 @@ class Button extends Component {
449469
450470
export default Button;
451471
```
452-
453-
7. Finally, let's open our ```App.js``` file in the /src directory to add our new Button Component to the App itself. Check below to see the example. Don't forget that we need to enclose the ```<Button />``` in two ```<div></div>``` tags!
454-
```javascript
455-
import React, { Component } from 'react';
456-
import logo from './logo.svg';
457-
import './App.css';
458-
459-
import Button from './components/Button';
460-
461-
class App extends Component {
462-
render() {
463-
return (
464-
<div>
465-
<Button />
466-
</div>
467-
);
468-
}
469-
}
470-
471-
export default App;
472-
```
473-
474472
This should be everything we need to setup the API. Simply click our test api call button and see the magic work!
475473

476474
Congratulations! Our Rails API and React Client is done! If you enjoyed this API tutorial please give it a star and share it with your friends!

0 commit comments

Comments
 (0)