Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3866 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3866 Rev 5066
Línea 1... Línea -...
1
import React from "react";
-
 
2
import { useEffect } from "react";
1
import React, { useEffect } from 'react'
-
 
2
 
3
import { useForm } from "react-hook-form";
3
import { useForm } from 'react-hook-form'
4
import { useLocation, useHistory } from "react-router-dom";
4
import { useLocation, useHistory } from 'react-router-dom'
Línea 5... Línea 5...
5
 
5
 
6
const SearchBar = () => {
6
const SearchBar = () => {
7
  const { register, handleSubmit, getValues, setValue } = useForm();
7
  const { register, handleSubmit, getValues, setValue } = useForm()
8
  const location = useLocation();
8
  const location = useLocation()
Línea 9... Línea 9...
9
  const history = useHistory();
9
  const history = useHistory()
10
 
10
 
11
  useEffect(() => {
11
  useEffect(() => {
12
    const keyword = new URLSearchParams(location.search).get("keyword");
12
    const keyword = new URLSearchParams(location.search).get('keyword')
Línea 13... Línea 13...
13
    setValue("keyword", keyword);
13
    setValue('keyword', keyword)
14
  }, []);
14
  }, [])
15
 
15
 
16
  const onSubmitHandler = (data, event) => {
16
  const onSubmitHandler = (data, event) => {
17
    history.push({
17
    history.push({
18
      pathname: location.pathname,
18
      pathname: location.pathname,
Línea 19... Línea 19...
19
      search: `?keyword=${getValues("keyword")}`,
19
      search: `?keyword=${getValues('keyword')}`
20
    });
20
    })
21
  };
21
  }
22
 
22
 
Línea 39... Línea 39...
39
            <button type="submit">Buscar</button>
39
            <button type="submit">Buscar</button>
40
          </form>
40
          </form>
41
        </div>
41
        </div>
42
      </div>
42
      </div>
43
    </div>
43
    </div>
44
  );
44
  )
45
};
45
}
Línea 46... Línea 46...
46
 
46