Overview
- JavaScript를 이용한 React 기초를 알아봅니다.
- TypeScript를 이용한 React 기초를 알아봅니다.
Index
Content
-
-
- Install Create-React-App
- npm
npm install -g create-react-app
- yarn
yarn global add create-react-app
- npm
-
cd $WorkSpace
cd $Your_Work_Space
- Install styled-components
- npm
npm install styled-components
- yarn
yarn add styled-components
- npm
- Install Create-React-App
-
-
-
-
Create-React-App
create-react-app dkant-react-javascript
-
dkant-react-javascript TreeView
├── README.md ├── node_modules │ └── ... ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json ├── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ └── serviceWorker.js └── yarn.lock
-
Start BoilerPlate
- npm
npm start
- yarn
yarn start
- npm
-
-
-
import React, { Component } from 'react'; import styled from 'styled-components'; const Header = styled.div` height: 100px; width: 100%; grid-area: header; background-color: red; `; const SideBar = styled.div` width: 200px; height: 100%; display: inline-block; grid-area: siderbar; background-color: green; `; const Content = styled.div` width: calc(100% - 200px); height: 100%; display: inline-block; grid-area: content; background-color: blue; `; const StyledMain = styled.div` width: 100%; height: calc(100% - 200px); grid-area: main; grid-template-areas: 'siderbar content'; `; const Footer = styled.div` width: 100%; height: 100px; grid-area: footer; background-color: black; `; const StyledLayout = styled.div` width: 100vw; height: 100vh; grid-template-areas: 'header' 'main' 'footer'; `; class Main extends Component { render() { return ( <StyledMain> <SideBar /> <Content /> </StyledMain> ); } } class Layout extends Component { render() { return ( <StyledLayout> <Header /> <Main /> <Footer /> </StyledLayout> ); } } class App extends Component { render() { return ( <div className="App"> <Layout /> </div> ); } } export default App;
Result
-
-
-
-
-
Create-React-App
create-react-app dkant-react-typescript --scripts-version=react-scripts-ts
-
dkant-react-typescript TreeView
├── README.md ├── node_modules │ └── ... ├── images.d.ts ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── logo.svg │ └── registerServiceWorker.ts ├── tsconfig.json ├── tsconfig.prod.json ├── tsconfig.test.json ├── tslint.json └── yarn.lock
- Start BoilerPlate
- npm
npm start
- yarn
yarn start
- npm
- TypeConfig
-
-