Closed cmolenda closed 7 months ago
https://github.com/foxhound87/mobx-react-form/issues/632
This bug was introduced in v6.4.0
In rare circumstances, creating a form class with a hooks method can cause the first trigger of the hook to fail.
Example:
import { Form } from "mobx-react-form"; import { makeObservable, flow } from "mobx"; let x = 0; class HookedForm extends Form { constructor() { super({ fields: ["aField"] }); makeObservable(this, { onSuccess: flow, }); } hooks() { return { onSuccess: this.onSuccess }; } *onSuccess() { alert(`onSuccess ${++x}`); } } export default function App() { return ( <div className="App"> <button onClick={() => new HookedForm().submit()}>Test</button> </div> ); }
Change the hook and handler objects to shallow observables, which prevents this problem.
:tada: This PR is included in version 6.7.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
https://github.com/foxhound87/mobx-react-form/issues/632
This bug was introduced in v6.4.0
In rare circumstances, creating a form class with a hooks method can cause the first trigger of the hook to fail.
Example:
Change the hook and handler objects to shallow observables, which prevents this problem.