formsy / formsy-react

A form input builder and validator for React JS
MIT License
763 stars 125 forks source link

Since v1, resetForm throws error #41

Closed adrienharnay closed 6 years ago

adrienharnay commented 6 years ago

Hey,

Since upgrading to v1 (1.1.1 to be precise), I have this error when calling resetForm:

TypeError: Cannot read property 'inputs' of undefined
    at resetModel (webpack:////Users/adrien/Documents/GitHub/brigad-front-end/node_modules/formsy-react/lib/index.js?:221:12)
    at eval (webpack:///./client/src/common/user-details/js/DisplayCreateUserStates/components/CreateUserState.js?:95:9)
    at _callee2$ (webpack:///./client/src/action-creators/jobSeeker/states.js?:196:17)
    at tryCatch (webpack:////Users/adrien/Documents/GitHub/brigad-front-end/node_modules/regenerator-runtime/runtime.js?:65:40)
    at Generator.invoke [as _invoke] (webpack:////Users/adrien/Documents/GitHub/brigad-front-end/node_modules/regenerator-runtime/runtime.js?:299:22)
    at Generator.prototype.(anonymous function) [as next] (webpack:////Users/adrien/Documents/GitHub/brigad-front-end/node_modules/regenerator-runtime/runtime.js?:117:21)
    at step (webpack:///./client/src/action-creators/jobSeeker/states.js?:21:221)
    at _next (webpack:///./client/src/action-creators/jobSeeker/states.js?:21:409)
    at <anonymous>

Everything works as expected though. Maybe something was broken in the big update?

Thanks in advance!

rkuykendall commented 6 years ago

Thanks for reporting this issue!

Looks like the issue here is a missing bind of resetModel in index.js. We had a similar issue in our Wrapper.js. The solution is definitely to remove all those binds and switch the file to use arrow functions.

rkuykendall commented 6 years ago

If nobody else wants to tackle this, I should be able to make a PR this weekend.

rkuykendall commented 6 years ago

Hey @Zephir77167, I haven't forgotten your issue, was just busy last weekend.

adrienharnay commented 6 years ago

Hey, totally understandable, thanks for following up :+1:

rkuykendall commented 6 years ago

This should fix the issue. Giving it a little time for people to review. If you're able to test it that would be great, but that might be easier once it's on master.

https://github.com/formsy/formsy-react/pull/44/files

rkuykendall commented 6 years ago

Hey @Zephir77167! formsy-react 1.1.2 is now published on NPM! Thank you for your patience. Let me know if this solved the bug you were encountering.

adrienharnay commented 6 years ago

Thank you very much for the fix! The bug is fixed :)