File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -199,32 +199,30 @@ Platform Admin. This is particularly useful to add custom validation rules:
199
199
200
200
``` javascript
201
201
import React , { Component } from ' react' ;
202
- import { AdminBuilder , hydraClient } from ' api-platform-admin' ;
203
- import parseHydraDocumentation from ' api-doc-parser/lib/hydra/parseHydraDocumentation' ;
202
+ import { AdminBuilder , hydraClient } from ' @ api-platform-admin' ;
203
+ import parseHydraDocumentation from ' @api-platform/ api-doc-parser/lib/hydra/parseHydraDocumentation' ;
204
204
205
205
const entrypoint = ' https://demo.api-platform.com' ;
206
206
207
207
export default class extends Component {
208
- state = {api: null };
208
+ state = { api: null };
209
209
210
210
componentDidMount () {
211
- parseHydraDocumentation (entrypoint).then ( ({ api }) => => {
211
+ parseHydraDocumentation (entrypoint).then ( ({ api }) => {
212
212
const books = api .resources .find (r => ' books' === r .name );
213
213
214
214
books .writableFields .find (f => ' description' === f .name ).inputProps = {
215
215
validate : value => value .length >= 30 ? undefined : ' Minimum length: 30' ;
216
216
};
217
217
218
- this .setState ({api: api});
219
-
220
- return { api };
218
+ this .setState ({ api });
221
219
});
222
220
}
223
221
224
222
render () {
225
223
if (null === this .state .api ) return < div> Loading... < / div> ;
226
224
227
- return < AdminBuilder api= {this .state .api } dataProvider= {hydraClient (entrypoint) }/ >
225
+ return < AdminBuilder api= { this .state .api } dataProvider= { hydraClient (this . state . api ) }/ >
228
226
}
229
227
}
230
228
```
You can’t perform that action at this time.
0 commit comments