Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite TextInput.jsx: formik.getFieldProps is not a function #38

Open
aterjung opened this issue Mar 15, 2023 · 7 comments
Open

Overwrite TextInput.jsx: formik.getFieldProps is not a function #38

aterjung opened this issue Mar 15, 2023 · 7 comments

Comments

@aterjung
Copy link

Hi,

i have some trouble overwriting
src/reactapp/src/components/common/Form/TextInput.jsx
Component to realise some custom styling. When i add a copy of the Component:

app/code/AktWeb/HyvaCheckout/reactapp/src/components/common/Form/TextInput.jsx

And modifiy the imports:

import { _replace } from '@hyva/react-checkout/utils';
import { formikDataShape } from '@hyva/react-checkout/utils/propTypes';

The checkout is broken with these Errormessage in the JS-Console:

bundle.js:39996 Uncaught TypeError: formik.getFieldProps is not a function
at Field (bundle.js:39996:22)
at renderWithHooks (bundle.js:61000:22)
at mountIndeterminateComponent (bundle.js:64286:17)
at beginWork (bundle.js:65582:20)
at HTMLUnknownElement.callCallback (bundle.js:50592:18)
at Object.invokeGuardedCallbackDev (bundle.js:50636:20)
at invokeGuardedCallback (bundle.js:50693:35)
at beginWork$1 (bundle.js:70567:11)
at performUnitOfWork (bundle.js:69814:16)
at workLoopSync (bundle.js:69737:9)

Could you imagine what is the reason for the error? Im lost at the moment.

thanks in advance

@rajeev-k-tomy
Copy link
Collaborator

Is there any usage of getFieldProps inside this component TextInput or any other part of your react app? If yes, probably you are using this outside formik context and that throws the error.

@aterjung
Copy link
Author

I don`t see any usage of getFieldProps inside the TextInput Component. Actually, i only copied the original file from reactcheckout source to my own folder as shown in the documentation here. I did not change anything more than modifing the imports.

@rajeev-k-tomy
Copy link
Collaborator

@aterjung Do you have its usage anywhere else in your project?

@aterjung
Copy link
Author

@rajeev-k-tomy the TextInput or the Formik context? Not for myself, but i copied the ShippingAddressForm.jsx as well, there is the original TextInput used.

@rajeev-k-tomy
Copy link
Collaborator

@aterjung I was asking whether there is any occurance of getFieldProps inside the reactapp directory?

@aterjung
Copy link
Author

@rajeev-k-tomy no, it is not. I greped for it and the only places found are inside the node_modules directory.
There is an other Error i did not recognised before:

Cannot read properties of undefined (reading 'touched')
TypeError: Cannot read properties of undefined (reading 'touched')
at ErrorMessageImpl.render (http://localhost:3000/static/js/bundle.js:40296:30)
at finishClassComponent (http://localhost:3000/static/js/bundle.js:63890:35)
at updateClassComponent (http://localhost:3000/static/js/bundle.js:63847:28)
at beginWork (http://localhost:3000/static/js/bundle.js:65473:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:50464:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:50508:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:50565:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:70439:11)
at performUnitOfWork (http://localhost:3000/static/js/bundle.js:69686:16)
at workLoopSync (http://localhost:3000/static/js/bundle.js:69609:9)

but this is more irritating than the first error to me.

@rajeev-k-tomy
Copy link
Collaborator

I am not quite getting it. But you can put a console command inside TextInput comment like console.log({formik}) to check whether it becomes empty in any of the cases. Ideally, it should not be empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants