App.js 1.78 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
import React, { useEffect, useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
import ohuh from './ohuh.PNG';
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
4
import { Col, FormControl, Container, Row, Form, Image, InputGroup, Button } from 'react-bootstrap';
Kim, Chaerin's avatar
Kim, Chaerin committed
5

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
6
7


Kim, Chaerin's avatar
Kim, Chaerin committed
8
function App() {
Kim, Chaerin's avatar
Kim, Chaerin committed
9
  const [state, setState] = useState(false);
Kim, Chaerin's avatar
Kim, Chaerin committed
10
  const [search, setSearch] = useState("");
Kim, Chaerin's avatar
Kim, Chaerin committed
11
12
13
14
15
16
17

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

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

Kim, Chaerin's avatar
Kim, Chaerin committed
23
  const handleSubmit = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
24
25
26
    setState(true);
  }

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
27

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
28

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

export default App;