🐛 FIX: Bug et améliorations globale

This commit is contained in:
Divlo
2020-04-23 01:08:54 +02:00
parent 032ef566c7
commit 4454f2e089
4 changed files with 15 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { Fragment, useState } from 'react';
import { Fragment, useState, useEffect } from 'react';
import Loader from './Loader';
import htmlParser from 'html-react-parser';
import dynamic from 'next/dynamic';
@ -16,6 +16,17 @@ const FunctionForm = (props) => {
const [message, setMessage] = useState("");
const [isLoading, setIsLoading] = useState(false);
// inputState par défaut
useEffect(() => {
const inputStateNew = { ...inputState };
props.inputsArray.forEach((input) => {
if (input.type === "select" && input.options.length > 0) {
inputStateNew[input.name] = input.options[0].value;
}
});
setInputState(inputStateNew);
}, []);
const handleSubmit = (event) => {
setIsLoading(true);
event.preventDefault();