I am using react-jsonschema-form to develop a form and I can not execute the function corresponding to the onSubmit button. I do not understand why it reloads the page when I press it and I do not execute the function.
const onSubmit = ({formData}) => console.log("Data submitted: ", formData);
class QuestionsSet extends React.Component {
render () {
return (
<section id="soyceliaco" className="section-padding text-justify">
<div className="container">
<div className="row">
<div className="col-md-12">
<h2 className="ser-title">Realizar cuestionario:</h2>
<hr className="botm-line"></hr>
</div>
<div className="col-md-12 col-sm-12">
<Form schema={schemaQuestions}
onSubmit={onSubmit} >
</Form>
</div>
</div>
</div>
</section>
);
}
}
export default QuestionsSet;
答案 0 :(得分:0)
You need to prevent default action like this
const onSubmit = ({formData},e) =>{ e.preventDefault(); console.log("Data submitted: ", formData)};
works, if onsubmit generates an 'event'