본문 바로가기
Frame-Work/React-JS

1. React 프로젝트 기본구조

by 깡돌JS 2021. 5. 18.


ㅁ 리액트 설치

https://nodejs.org/ko/

 

Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

14.17.0 LTS 설치

CMD > npx create-react-app [프로젝트 이름 작명]


App.css

.App {

  text-aligncenter;

}

 

.App-logo {

  height40vmin;

  pointer-eventsnone;

}

 

@media (prefers-reduced-motion: no-preference) {

  .App-logo {

    animation: App-logo-spin infinite 20s linear;

  }

}

 

.App-header {

  background-color#282c34;

  min-height100vh;

  displayflex;

  flex-directioncolumn;

  align-itemscenter;

  justify-contentcenter;

  font-sizecalc(10px + 2vmin);

  colorwhite;

}

 

.App-link {

  color#61dafb;

}

 

@keyframes App-logo-spin {

  from {

    transformrotate(0deg);

  }

  to {

    transformrotate(360deg);

  }

}


App.js

import logo from './logo.svg';

import './App.css';

 

function App() {

  return (

    <div className="App">

      <header className="App-header">

        <img src={logo} className="App-logo" alt="logo" />

        <p>

          Edit <code>src/App.js</code> and save to reload.

        </p>

        <a

          className="App-link"

          href="https://reactjs.org"

          target="_blank"

          rel="noopener noreferrer"

        >

          Learn React

        </a>

      </header>

    </div>

  );

}

 

export default App;


index.css

body {

  margin0;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI''Roboto''Oxygen',

    'Ubuntu''Cantarell''Fira Sans''Droid Sans''Helvetica Neue',

    sans-serif;

  -webkit-font-smoothingantialiased;

  -moz-osx-font-smoothinggrayscale;

}

 

code {

  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',

    monospace;

}


index.js

import React from 'react';

import ReactDOM from 'react-dom';

import './index.css';

import App from './App';

import reportWebVitals from './reportWebVitals';

 

ReactDOM.render(

  <React.StrictMode>

    <App />

  </React.StrictMode>,

  document.getElementById('root'// index.html root > DOM

);

 

// If you want to start measuring performance in your app, pass a function

// to log results (for example: reportWebVitals(console.log))

// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals

reportWebVitals();  // 퍼포먼스 관련


reportWebVitals.js

const reportWebVitals = onPerfEntry => {

  if (onPerfEntry && onPerfEntry instanceof Function) {

    import('web-vitals').then(({ getCLSgetFIDgetFCPgetLCPgetTTFB }) => {

      getCLS(onPerfEntry);

      getFID(onPerfEntry);

      getFCP(onPerfEntry);

      getLCP(onPerfEntry);

      getTTFB(onPerfEntry);

    });

  }

};

 

export default reportWebVitals;


setupTests.js

// jest-dom adds custom jest matchers for asserting on DOM nodes.

// allows you to do things like:

// expect(element).toHaveTextContent(/react/i)

// learn more: https://github.com/testing-library/jest-dom

import '@testing-library/jest-dom';


.gitignore

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

 

# dependencies

/node_modules

/.pnp

.pnp.js

 

# testing

/coverage

 

# production

/build

 

# misc

.DS_Store

.env.local

.env.development.local

.env.test.local

.env.production.local

 

npm-debug.log*

yarn-debug.log*

yarn-error.log*


package.json

{

  "name""voca",

  "version""0.1.0",

  "private"true,

  "dependencies": {

    "@testing-library/jest-dom""^5.12.0",

    "@testing-library/react""^11.2.7",

    "@testing-library/user-event""^12.8.3",

    "react""^17.0.2",

    "react-dom""^17.0.2",

    "react-scripts""4.0.3",

    "web-vitals""^1.1.2"

  },

  "scripts": {

    "start""react-scripts start",

    "build""react-scripts build",

    "test""react-scripts test",

    "eject""react-scripts eject"

  },

  "eslintConfig": {

    "extends": [

      "react-app",

      "react-app/jest"

    ]

  },

  "browserslist": {

    "production": [

      ">0.2%",

      "not dead",

      "not op_mini all"

    ],

    "development": [

      "last 1 chrome version",

      "last 1 firefox version",

      "last 1 safari version"

    ]

  }

}


 

'Frame-Work > React-JS' 카테고리의 다른 글

6. React - props(속성값)  (0) 2021.05.18
5. React - State, useState(상태값)  (0) 2021.05.18
4. React - 이벤트 처리(Handing Events)  (0) 2021.05.18
3. React - CSS 만들기  (0) 2021.05.18
2. React - Component 만들기  (0) 2021.05.18

댓글