@@ -38,16 +38,19 @@ Bootstrap 4 - from release 0.1.16
38
38
39
39
In the app directory, generate the files for the resource you want:
40
40
41
- $ generate-api-platform-client https://demo.api-platform.com src/ --resource foo
42
- # Replace the URL by the entrypoint of your Hydra-enabled API
43
- # Omit the resource flag to generate files for all resource types exposed by the API
41
+ ``` bash
42
+ $ generate-api-platform-client https://demo.api-platform.com src/ --resource book
43
+ # Replace the URL by the entrypoint of your Hydra-enabled API
44
+ # Omit the resource flag to generate files for all resource types exposed by the API
45
+ ```
44
46
45
47
The code is ready to be executed! Register the generated reducers and components in the ` index.js ` file, here is an example:
46
48
47
49
``` javascript
48
50
import React from ' react' ;
49
- import ReactDom from ' react-dom' ;
50
- import registerServiceWorker from ' ./registerServiceWorker' ;
51
+ import ReactDOM from ' react-dom' ;
52
+ import * as serviceWorker from ' ./serviceWorker' ;
53
+
51
54
import { createStore , combineReducers , applyMiddleware } from ' redux' ;
52
55
import { Provider } from ' react-redux' ;
53
56
import thunk from ' redux-thunk' ;
@@ -56,28 +59,31 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
56
59
import createBrowserHistory from ' history/createBrowserHistory' ;
57
60
import { syncHistoryWithStore , routerReducer as routing } from ' react-router-redux'
58
61
59
- // Replace "foo " with the name of the resource type
60
- import foo from ' ./reducers/foo /' ;
61
- import fooRoutes from ' ./routes/foo ' ;
62
+ // Replace "book " with the name of the resource type
63
+ import book from ' ./reducers/book /' ;
64
+ import bookRoutes from ' ./routes/book ' ;
62
65
63
66
const store = createStore (
64
- combineReducers ({routing, form, foo }), // Don't forget to register the reducers here
67
+ combineReducers ({routing, form, book }), // Don't forget to register the reducers here
65
68
applyMiddleware (thunk),
66
69
);
67
70
68
71
const history = syncHistoryWithStore (createBrowserHistory (), store);
69
72
70
- ReactDom .render (
73
+ ReactDOM .render (
71
74
< Provider store= {store}>
72
75
< Router history= {history}>
73
76
< Switch>
74
- {fooRoutes }
77
+ {bookRoutes }
75
78
< Route render= {() => < h1> Not Found< / h1> }/ >
76
79
< / Switch>
77
80
< / Router>
78
81
< / Provider> ,
79
82
document .getElementById (' root' )
80
83
);
81
84
82
- registerServiceWorker ();
85
+ // If you want your app to work offline and load faster, you can change
86
+ // unregister() to register() below. Note this comes with some pitfalls.
87
+ // Learn more about service workers: http://bit.ly/CRA-PWA
88
+ serviceWorker .unregister ();
83
89
```
0 commit comments