Skip to content

Commit b0af34d

Browse files
authored
fix not working code
1. change ReactDom to ReactDOM https://stackoverflow.com/questions/33125669/uncaught-referenceerror-reactdom-is-not-defined 2. change foo to book 3. add bash code block
1 parent b67bc75 commit b0af34d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

client-generator/react.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ Bootstrap 4 - from release 0.1.16
3838

3939
In the app directory, generate the files for the resource you want:
4040

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+
```
4446

4547
The code is ready to be executed! Register the generated reducers and components in the `index.js` file, here is an example:
4648

4749
```javascript
4850
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+
5154
import { createStore, combineReducers, applyMiddleware } from 'redux';
5255
import { Provider } from 'react-redux';
5356
import thunk from 'redux-thunk';
@@ -56,28 +59,31 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
5659
import createBrowserHistory from 'history/createBrowserHistory';
5760
import { syncHistoryWithStore, routerReducer as routing } from 'react-router-redux'
5861

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';
6265

6366
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
6568
applyMiddleware(thunk),
6669
);
6770

6871
const history = syncHistoryWithStore(createBrowserHistory(), store);
6972

70-
ReactDom.render(
73+
ReactDOM.render(
7174
<Provider store={store}>
7275
<Router history={history}>
7376
<Switch>
74-
{fooRoutes}
77+
{bookRoutes}
7578
<Route render={() => <h1>Not Found</h1>}/>
7679
</Switch>
7780
</Router>
7881
</Provider>,
7982
document.getElementById('root')
8083
);
8184

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();
8389
```

0 commit comments

Comments
 (0)