nico
Published in : 2022-02-14
When we select a data we get the error please see the codesandbox below
Cannot read properties of undefined (reading 'type')
we must be able to select a date
See
//codesandbox.io/s/formik-codesandbox-template-forked-xonzi?file=/index.js
"@emotion/react": "^11.7.1","@emotion/styled": "^11.6.0","@material-ui/core": "^4.12.3","@material-ui/lab": "^4.0.0-alpha.60","@mui/lab": "^5.0.0-alpha.68","@mui/material": "^5.4.1","@mui/x-data-grid": "^5.5.0","axios": "^0.25.0","bootstrap": "^4.6.1","date-fns": "^2.28.0","formik": "^2.2.9","jquery": "^3.6.0","material-ui-search-bar": "^1.0.0","merge": "^2.1.1","oidc-client": "^1.11.5","react": "^16.0.0","react-bootstrap": "^2.1.2","react-dom": "^16.0.0","react-loader-spinner": "^5.1.0","react-redux": "^7.2.6","react-router-bootstrap": "^0.25.0","react-router-dom": "^5.1.2","react-sortable-tree": "^2.8.0","reactstrap": "^8.4.1","redux-logger": "^3.0.6","redux-thunk": "^2.4.1","rimraf": "^2.6.2","semantic-ui-css": "^2.4.1","semantic-ui-react": "^2.1.1","uuid": "^8.3.2"
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Mohamed Atef Date : 2022-02-14
Best answers
51
Best answers
51
Hello Nico, Thank you for using Web-Brackets.com, you are using a different way to get the data onChange so the function which called formik.handleChange doesn't work because somehow the event does not pass to handleChange so you do it in this way
so the full code should looks like
this will not make an error when you select a date but the point is setting the value to the form you can do it using a function called setFieldValue and it should be use like this
Good luck
nico Date : 2022-02-14
Best answers
4
Best answers
4
Thanks Mohamed for your kind help, I resolved the problem meanwhile and used the solution you adviced.
Your answer confirms that I took the right direction ! :)
The forum is good ! I posted my question to the github of formik and also of mui, no answer all day long, seems to be dead or dead slow…
To remind the full context
My code didn't work first because
so to fully resolve my problem i did use the same solution you advise:
Date.parse(value) is the number of ms of the date selected, Date.now() is the number of ms of the current date.
Mohamed Atef Date : 2022-02-14
Glad you find the solution :)
nico Date : 2022-02-14
Thanks Mohamed again.
I started using React only 2 weeks ago with asp.net core as web api.
Can you advice me books, websites to master asap react, redux for the front with asp.net core for the backend?
I guess you work more with nodejs, react than with asp.net core though :)
So any good resource for react, redux etc will be welcome. شكرا
Mohamed Atef Date : 2022-02-14
You can check this Youtube channel //youtu.be/Ke90Tje7VS0
And then you can move to other websites & sources especially the documentation but for the ASP.net I have no idea about it
Mati Date : 2022-06-24
Thank you verymuch both of you guys !! This post was the only one that helped me to resolve my problem with the data Picker and formik!!
Seba Alfaro Date : 2022-08-02
Thanks both guys! I had the same problem, I searched several forums but could't find the solution until now