App.js 1.59 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useEffect, useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
import ohuh from './ohuh.PNG';
import { Container, Row, Col, Image, InputGroup, FormControl, Button } from 'react-bootstrap';

function App() {
  const [search, setSearch] = useState("");
  const [state, setState] = useState();

  useEffect(() => {
    if (state === true) {
      <Redirect to="/search" />
      // <Redirect to={{
      //   pathname: `/search/${search}`,
      //   state: { id: search },
      // }} />
    }
  }, [])

  const handleChange = (e) => {
    setSearch(e.target.value);
    console.log(e.target.value)
  }

  const handleSubmit = (e) => {
    setState(true);
  }

  return (
    <Container className="min-height 100vh">
      <Row className="justify-content-md-center" >
        <Image src={ohuh} />
      </Row>
      <Row>
        <InputGroup size="lg">
          <FormControl
            placeholder="검색어를 입력하세요."
            aria-label="Large"
            aria-describedby="inputGroup-sizing-sm"
            onChange={handleChange}
          />
          <InputGroup.Append>
            <Button variant="outline-secondary" onClick={handleSubmit}><Link to="/search">검색</Link></Button>
          </InputGroup.Append>
        </InputGroup>
        {/* <form onSubmit={handleSubmit}>
          <input className="" name="search" type="text" placeholder="검색어를 입력하세요." onChange={handleChange}></input>
          <Link to="/search"><button type="submit">검색</button></Link>
        </form> */}
      </Row>
    </Container>
  );
}

export default App;