You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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.
Copy file name to clipboardExpand all lines: README.md
+22-24Lines changed: 22 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -368,10 +368,30 @@ class Button extends Component {
368
368
369
369
exportdefaultButton;
370
370
```
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
+
importReact, { Component } from'react';
374
+
importlogofrom'./logo.svg';
375
+
import'./App.css';
376
+
377
+
importButtonfrom'./components/Button';
378
+
379
+
classAppextendsComponent {
380
+
render() {
381
+
return (
382
+
<div>
383
+
<Button />
384
+
</div>
385
+
);
386
+
}
387
+
}
371
388
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
+
exportdefaultApp;
390
+
```
373
391
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:
@@ -449,28 +469,6 @@ class Button extends Component {
449
469
450
470
export default Button;
451
471
```
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
-
474
472
This should be everything we need to setup the API. Simply click our test api call button and see the magic work!
475
473
476
474
Congratulations! Our Rails API and React Client is done! If you enjoyed thisAPI tutorial please give it a star and share it with your friends!
0 commit comments