api-platform / create-client

Generate React or Vue.js-based Progressive Web Apps from an Hydra-enabled API. Also support React Native.
https://api-platform.com/docs/client-generator/
MIT License
373 stars 132 forks source link

React generator error: Field missing from import #243

Closed walva closed 3 years ago

walva commented 3 years ago

API Platform Client Generator affected: >= 0.5.0

Description
In a generated react client the following error occurs: Failed to compile 'Field' is not defined react/jsx-no-undef. It occurs in ./src/component/{entity name}/Form.js for each Field. It worked after I changed client/src/components/{entity name}/Form.js line 2 from: import { reduxForm } from 'redux-form'; to: import { Field, reduxForm } from 'redux-form'; Probably caused by the change in templates/react/components/foo/Form.js in commit: "fix tests" committed Oct 24, 2020 https://github.com/api-platform/client-generator/commit/7d740dc0e262ad0345da6d57ffe34669dc63a65e#diff-929e3b2ef753bdeb716342d2ce2632ab9094af8e6694bc8f9382c173466514c9 How to reproduce

Possible Solution
Revert the line 2 change in templates/react/components/foo/Form.js; by importing Field.

import { Field, reduxForm } from 'redux-form';

Additional Context
image

Many thanks to @metaclass-nl who helped me a lot.