App.js 1.33 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 } 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">
Kim, Chaerin's avatar
Kim, Chaerin committed
32
        <Image src={ohuh} />
33
34
35
36
37
38
      </Row>
      <Row className="d-flex justify-content-md-center">
        <Form className="vw-100" onSubmit={handleSubmit}>
          <InputGroup>
            <Form.Control
              size="lg"
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
39
40
41
42
43
44
              placeholder="검색어를 입력하세요."
              aria-label="Large"
              aria-describedby="inputGroup-sizing-sm"
              onChange={handleChange}
            />
            <InputGroup.Append>
45
              <Button type='submit' variant="outline-secondary">검색</Button>
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
46
47
            </InputGroup.Append>
          </InputGroup>
48
        </Form>
Kim, Chaerin's avatar
Kim, Chaerin committed
49
50
51
52
53
54
      </Row>
    </Container>
  );
}

export default App;