Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4250 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useEffect, useState } from "react";
3
import SearchInput from './SearchInput'
4
 
5
const Searchbox = ({ show, onClose }) => {
6
 
7
  const [shouldRender, setShouldRender] = useState(show);
8
 
9
  const handleUnmount = () => {
10
    if (!show) setShouldRender(false);
11
  };
12
 
13
  useEffect(() => {
14
    if (show) setShouldRender(show);
15
  }, [show]);
16
 
17
 
18
  return (
19
    shouldRender &&
20
    <>
21
      <div className={`searchBox ${show ? 'fadeIn' : 'fadeOut'}`} onAnimationEnd={handleUnmount}>
22
        <SearchInput />
23
      </div>
24
      <div className='backdrop' onClick={onClose}></div>
25
    </>
26
  )
27
};
28
 
29
export default Searchbox;