React: formik form, how to use state after submit inside a callback function
问题 I am using formik plugin in reactjs and I want to useState variables after form submit. Both this and setState are undefined and I can't achieve it. Can anybody please help me to get this done? See screenshot (below) 回答1: In JavaScript , class methods are not bound by default. If you forget to bind this.LoginApp and pass it to onSubmit , this will be undefined when the function is actually called (as you already noted). This is not React-specific behavior; it is a part of how functions work