App.js 1.64 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
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("");
Kim, Chaerin's avatar
Kim, Chaerin committed
8
9
10
11
12
13
14
15
  const [state, setState] = useState(false);

  if (state !== false) {
    return <Redirect to={{
      pathname: `/search/${search}`,
      state: { id: search },
    }} />;
  }
Kim, Chaerin's avatar
Kim, Chaerin committed
16
17
18
19
20
21
22
23
24
25

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

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

Kim, Chaerin's avatar
Kim, Chaerin committed
26
27


Kim, Chaerin's avatar
Kim, Chaerin committed
28
  return (
Kim, Chaerin's avatar
Kim, Chaerin committed
29
30
    <Container className="vh-100">
      <Row className="d-flex justify-content-md-center">
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
          <Image src={ohuh} />
          <Col lg={{span:9, offset:1}} xs={{span: 12, offset:3}}>
          <InputGroup size="lg" lg={6} xs={5}>
            <FormControl
              className="d-flex justify-content-lg-center"
              placeholder="검색어를 입력하세요."
              aria-label="Large"
              aria-describedby="inputGroup-sizing-sm"
              onChange={handleChange}
            />
            <InputGroup.Append>
              <Button variant="outline-secondary" onClick={handleSubmit}>검색</Button>
            </InputGroup.Append>
          </InputGroup>
          {/* <form onSubmit={handleSubmit}>
Kim, Chaerin's avatar
Kim, Chaerin committed
46
47
48
          <input className="" name="search" type="text" placeholder="검색어를 입력하세요." onChange={handleChange}></input>
          <Link to="/search"><button type="submit">검색</button></Link>
        </form> */}
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
49
50
        </Col>
        </Row>
Kim, Chaerin's avatar
Kim, Chaerin committed
51
52
53
54
55
    </Container>
  );
}

export default App;