App.js 1.39 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
2
import React, { useState } from 'react';
import { Redirect } from 'react-router-dom';
Kim, Chaerin's avatar
?    
Kim, Chaerin committed
3
import ohuh from '../ohuh.PNG';
baesangjune's avatar
baesangjune committed
4
import { Container, Row, Form, Image, InputGroup, Button, Col } from 'react-bootstrap';
Kim, Chaerin's avatar
?    
Kim, Chaerin committed
5
6
7
8
9
10

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

  if (state !== false) {
Kim, Chaerin's avatar
Kim, Chaerin committed
11
    return <Redirect to={`/search?keyword=${search}`} />;
Kim, Chaerin's avatar
?    
Kim, Chaerin committed
12
13
14
15
16
17
18
19
20
21
22
  }

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

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

  return (
Kim, Chaerin's avatar
서연    
Kim, Chaerin committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    <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
45
46
47
48
49
    </Container>
  );
}

export default App;