Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 9469 | Rev 9685 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 9469 Rev 9682
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
-
 
2
import { useForm } from 'react-hook-form'
-
 
3
import axios from 'axios'
-
 
4
 
-
 
5
const FormView = ({ actionLink }) => {
-
 
6
 
-
 
7
  const { handleSubmit, register } = useForm()
-
 
8
 
-
 
9
  const onSubmit = (data) => {
-
 
10
    axios.post(actionLink, data)
-
 
11
      .then(({ data }) => {
-
 
12
        if (!data.success) {
-
 
13
          console.log("Ocurrio un error")
-
 
14
        }
-
 
15
 
-
 
16
        console.log(data.data)
-
 
17
      })
-
 
18
      .catch(err => console.log(err))
-
 
19
  }
Línea 2... Línea -...
2
 
-
 
3
const FormView = () => {
20
 
-
 
21
  return (
-
 
22
    <section className="content">
-
 
23
      <div className="row" >
-
 
24
        <div className="col-xs-12 col-md-12">
-
 
25
          <form onSubmit={handleSubmit(onSubmit)}>
-
 
26
            <div className="form-group">
-
 
27
              <label>Nombre</label>
4
  return (
28
              <input type="text" name="name" className="form-control" ref={register} />
-
 
29
            </div>
-
 
30
 
-
 
31
          </form>
-
 
32
        </div>
-
 
33
      </div>
-
 
34
    </section>
5
    <div>FormView</div>
35
 
6
  )
36
  )
7
}
37
}
8
export default FormView
38
export default FormView