App.js 1.46 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';
4
import { Container, Row, Form, Image, InputGroup, Button, Col } from 'react-bootstrap';
Kim, Chaerin's avatar
Kim, Chaerin committed
5
6

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

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

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

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

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


Kim, Chaerin's avatar
Kim, Chaerin committed
27
  return (
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    <Container className="vh-100 d-flex justify-content-md-center align-items-center">
      <Col md={6} lassName=" d-flex justify-content-center">
        <Row style={{marginBottom:20}}>
          <Image src={ohuh} />
        </Row>

        <Row style={{marginBottom:500}}>
          <Form className="vw-100" onSubmit={handleSubmit}>
            <InputGroup>
              <Form.Control
                size="lg"
                placeholder="검색어를 입력하세요."
                aria-label="Large"
                aria-describedby="inputGroup-sizing-sm"
                onChange={handleChange}
              />
              <InputGroup.Append>
                <Button type='submit' variant="outline-secondary">검색</Button>
              </InputGroup.Append>
            </InputGroup>
          </Form>
        </Row>
      </Col>

Kim, Chaerin's avatar
Kim, Chaerin committed
52
53
54
55
    </Container>
  );
}

56
export default App;