score:10
Accepted answer
Firstly remove type="submit"
. Because formik
will understand it like submit and will validate it. Second add onClick
function:
<Button
variant="contained"
color="secondary"
onClick={() => handleSave(props.values)} >Save</Button>
And:
const handleSave = (values) => {
// do what you want like on submit
}
Source: stackoverflow.com
Related Query
- Formik React with 2 buttons (Submit and Save) to submit form - Save button not to trigger validation
- react formik disable submit button with form validity
- How to make form not refresh with custom submit button in React
- How to submit a form with radio buttons in react and increment the state by one based on the value submitted?
- React formik form validation: How to initially have submit button disabled
- React Formik - Validating Form on Component Re-Mounting and Enabling Button
- Creating reusable Button Component with React and Typescript with not assignable type error
- React - Ant Design, Form with getFieldDecorator and initialValue not working in single chechbox
- "this" is undefined for a form after submit but not for button in react
- React useEffect(), fetch data with React Hooks and set the formik form
- How to Create a dropdown Button with see more option and on click toggle should not happen in react js?
- Button input type submit not submitting in React with React Router
- How to test react form onSubmit with formik and react testing library?
- On an HTML form with two buttons, how can I get one button to submit the form and the other one not?
- how to test button that call submit form using jest and react testing library
- React Select not showing errors when validating with Formik and Yup
- React form not displaying the correct inputs on the screen after I click submit button
- React button component with a conditional is not working and displaying
- React Webpack - Submit Button not retrieving input value on form submit
- How to get id of a button in a form with two buttons both from type submit
- React material-ui and reactstrap form inline with button new line
- Form not Submitting in React using Formik and Yup
- Can't perform a React state update with Formik on form submit
- Disabling Submit button on click with useRef (to prevent double clicks) inside a Formik form causes Formik submission to break
- New React with Material-UI Typography and Button component font-weights are not displaying right
- Dynamic form additions and deletions, data with new, UI is not new of antd with React
- Bootstrap validator submit button is not working with react api calls
- e.preventDefault not working when I trigger it from Submit button but working when triggered from onSubmit attribute in Form tag in React
- Buttons to change only when the it's checkbox is checked and the submit button is clicked in react project
- How to submit a form with react and redux?
More Query from same tag
- Fetch not working after switch from class to functional component
- Can't get the updated value in the context provider
- Async function with one try catch block
- React time ago not getting date
- React TypeError: items.map is not a function componentDidMount/< this.setState({
- How to change the state of one class from a function in a different class
- How to dispatch action from a child window?
- Is it possible to write this a shorter way in React using onClick?
- Node 'crypto' SHA256 hashing model behaving erratically
- ReactJs: How to get proper variable from Router path link?
- ReactJS with useRef: focusing a toggle-able form
- How can I not have duplicate value in shopping cart made with react using Context API?
- React state reference within onClick is wrong - possible closure issue?
- How to update a single property of the state in a react hook?
- Data not getting displayed from fetching from an api
- How to change colors in react component
- How to access component form data in a Redux `matchDispatchToProps` function?
- Function is not getting called anymore, when trying to dispatch a type
- Display saved text onclick in React.js
- req.params from app.delete is empty, using express, axios, in react
- How to get parent props/state from grandchild in reactjs
- How to call a component's onClick prop for testing purposes?
- Styling Nested Components in Styled-Components
- React Router v6 useRouteMatch equivalent
- React Native firebase Authentication handling
- ReactJS component state change rendered but then immediately revert back to initial state
- Unit Testing AntD Modal with Jest and Enzyme
- Adding ReactJS to a project without npm start
- Reactjs together with TinyMCE editor code plugin
- Using ReactType with JSX