inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] React로 NodeBird SNS 만들기

antd와 styled-components

ant-design login form이 위쪽 정렬이 되는데 해결방법이 있을까요?

해결된 질문

991

작성자 없음

작성한 질문수 0

0

안녕하세요 제로초님 강의들으면서 제 개인 프로젝트에 개념을 대입하면서 실습하고 있는데

 

홈페이지 header부분의 로그인폼이 아무리해도 가운데정렬이 되지 않아서 질문드립니다.

 

flex도 써보고 강의에 나온 verticalAlign을 써보고 구글링으로 답을 찾아봐도 안나와서 이렇게 질문드립니다.

 

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import Link from 'next/link';
import { Row, Col } from 'antd';

import LoggedinMenu from './LoggedinMenu';
import UnLoggedinMenu from './UnLoggedinMenu';

const AppLayout = ({ children }) => {
  const [isLoggedIn, setIsLoggedIn] = useState(false);  

  return (
    <>
        <Row style={{display: 'flex', justifyContent: 'space-between'}}>
          <Col>
            <Link href='/'><a><h1>Recipe.io</h1></a></Link>                    
          </Col>

          <Col>
            {isLoggedIn ? <LoggedinMenu setIsLoggedIn={setIsLoggedIn} /> : <UnLoggedinMenu setIsLoggedIn={setIsLoggedIn} />}
          </Col>
        </Row>     
    
      {children}
    </>
  )
};

AppLayout.propTypes = {
  children: PropTypes.node.isRequired,
}

export default AppLayout;
import React, { useCallback } from 'react';
import { Form, Input, Button } from 'antd';
import Link from 'next/link';
import PropTypes from 'prop-types';

const UnLoggedinMenu = ({ setIsLoggedIn }) => { 
  const onSubmitForm = useCallback((value) => {
    console.log(value);    
    setIsLoggedIn(true);
  }, []);

  return (    
    <Form onFinish={onSubmitForm} name="loginForm" style={{ display: 'flex'}}>
      <Form.Item               
        name="user-id"
        rules={[
          {
            type: 'text',
          },
          {
            required: true,
            message: '아이디를 입력하세요.',
          }
        ]}
      >
        <Input placeholder='Enter your Id'/>
      </Form.Item>

      <Form.Item
        name="user-password"
        rules={[
          {
            required: true,
            message: '비밀번호를 입력하세요.',
          }
        ]}
      >                
        <Input.Password placeholder='Enter your Password' />
      </Form.Item>
        
      <Form.Item>
        <Button type='primary' htmlType='submit'>로그인</Button>
      </Form.Item>

      <Form.Item>
        <Link href='/signup'><a><Button type='primary'>회원가입</Button></a></Link>
      </Form.Item>
    </Form>
  )
};

UnLoggedinMenu.propTypes = {
  setIsLoggedIn: PropTypes.func.isRequired,
}

export default UnLoggedinMenu;

 

 

Next.js nodejs express redux react

답변 1

0

제로초(조현영)

Form.Item들에 vertical-align을 주시거나 Form에서 alignItems: center를 주셔야할 것 같습니다.

넥스트 버젼 질문

0

90

2

로그인시 401 Unauthorized 오류가 뜹니다

0

104

1

무한 스크롤 중 스크롤 튐 현상

0

199

1

특정 페이지 접근을 막고 싶을 때

0

117

2

createGlobalStyle의 위치와 영향범위

0

104

2

인라인 스타일 리렌더링 관련

0

98

2

vsc 에서 npm init 설치시 오류

0

159

2

nextjs 15버전 사용 가능할까요?

0

166

1

화면 새로고침 문의

0

129

1

RTK에서 draft, state 차이가 있나요?

0

164

2

Next 14 사용해도 될까요?

0

455

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

359

1

url 오류 질문있습니다

0

218

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

393

1

sudo certbot --nginx 에러

0

1296

2

Minified React error 콘솔에러 (hydrate)

0

481

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

257

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

341

1

npm run build 에러

0

526

1

front 서버 npm run build 중에 발생한 에러들

0

399

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

351

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

291

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

252

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

207

1