250x250
Rainbow๐ŸŒˆCoder
My dev Note๐Ÿ“’
Rainbow๐ŸŒˆCoder
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (411)
    • ๊ณต์ง€์‚ฌํ•ญ (0)
    • Debugger (10)
      • Visual Studio Debugger (1)
      • Chrome DevTools (3)
      • Visual Studio Code Debugger (4)
      • eclipse (1)
      • intelliJ (1)
    • OOP (2)
      • OOP (2)
    • TypeScript (54)
      • ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ TypeScript (54)
    • Javascript (87)
      • Javascript (45)
      • Node.js (19)
      • React (5)
      • FE ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ค์ • (3)
      • React์™€ Node ๊ฐ™์ด ๋•Œ๋ ค์žก๊ธฐ (6)
      • next.js (2)
      • pixi.js (7)
    • ๋งˆํฌ์—… (23)
      • Html & Css (23)
    • C# (80)
      • C# (12)
      • ์ด๊ฒƒ์ด C#์ด๋‹ค (68)
    • C++ (30)
      • c++ (27)
      • win api (3)
    • Unity (18)
      • Unity(๊ธฐ์ดˆ) (8)
      • Unity(C#์ค‘๊ธ‰) (5)
      • ์œ ๋‹ˆํ‹ฐ ํฌํ†ค(๋„คํŠธ์›Œํฌ) (4)
      • unity c# MyCode (1)
    • Java & Spring (29)
      • Java (11)
      • ์Šคํ”„๋ง (8)
      • Java Algorithm (9)
      • Javs Data Structures (1)
    • ์ž๋ฃŒ๊ตฌ์กฐ์™€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ (15)
      • ์ž๋ฃŒ๊ตฌ์กฐ (5)
      • ์•Œ๊ณ ๋ฆฌ์ฆ˜ (10)
    • ํ˜•์ƒ๊ด€๋ฆฌ (15)
      • Git (11)
      • ์†Œ์ŠคํŠธ๋ฆฌ (3)
    • ๊ทธ๋ž˜ํ”ฝ์Šค (7)
      • WebGl (7)
    • AWS (3)
      • aws (3)
    • ๋ฆฌ๋ˆ…์Šค (5)
      • ๋ฆฌ๋ˆ…์Šค (5)
    • ์ฑ… ๋ฆฌ๋ทฐ (13)
      • ํด๋ฆฐ์ฝ”๋“œ(์ฑ…๋ฆฌ๋ทฐ) (3)
      • ์œ ์ง€๋ณด์ˆ˜๊ฐ€๋Šฅํ•œ์ฝ”๋”ฉ์˜๊ธฐ์ˆ C#ํŽธ(์ฑ…๋ฆฌ๋ทฐ) (1)
      • ๋ฆฌํŒฉํ† ๋ง(์ž๋ฐ”์Šคํฌ๋ฆฝํŠธํŒ) (9)
    • Server (2)
      • ๊ฒŒ์ž„ ์„œ๋ฒ„(๋„คํŠธ์›Œํฌ, ๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋“œ,OS) (2)
    • ์„ค๊ณ„, ์•„ํ‚คํ…์ณ (4)
    • ํŒŒ์ด์ฌ (5)
    • ๋””์ž์ธํŒจํ„ด (2)
    • mocha (2)
    • Jest (1)
    • Spine (1)
    • ์ธ๊ณต์ง€๋Šฅ (1)
      • ํ˜ผ์ž๊ณต๋ถ€ํ•˜๋Š”๋จธ์‹ ๋Ÿฌ๋‹+๋”ฅ๋Ÿฌ๋‹ (1)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

  • MySQL
  • ใ…ฃใ„ท
  • ์ปดํฌ์ง€์…˜
  • ์œ„์ž„

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
Rainbow๐ŸŒˆCoder

My dev Note๐Ÿ“’

[๋ฆฌ์•กํŠธ] ํ™˜๊ฒฝ์„ค์ •
Javascript/React

[๋ฆฌ์•กํŠธ] ํ™˜๊ฒฝ์„ค์ •

2022. 5. 7. 01:26
728x90

์š”์•ฝ: 

npx create-react-app ํด๋”๋ช…

npm start

 

์‹ฑ๊ธ€ํŽ˜์ด์ง€์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ธ ๋ฆฌ์•กํŠธ๋Š” ๋งค ํŽ˜์ด์ง€๋ฅผ ์ „ํ™˜ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ํ•˜๋‚˜์˜ HTML ํŽ˜์ด์ง€ ์•ˆ์—์„œ ๊ณ„์† ์ƒˆ๋กœ์šด ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๋‚˜๊ฐ€๋Š” ํ˜•์‹(์•ˆ์— ์žˆ๋Š” ๋‚ด์šฉ๋งŒ ๊ณ„์† ๋ฐ”๊ฟ”์คŒ)์œผ๋กœ,

ํŽ˜์ด์ง€๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ์ธ ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด๊ฒŒ๋” ํ•œ๋‹ค.

์ฆ‰, ์›น์„ ์•ฑ์ฒ˜๋Ÿผ ๋ณด์—ฌ์ฃผ๊ฒŒ ๋งŒ๋“œ๋Š” ๋ˆˆ์†์ž„์„ ๊ฐ€๋Šฅ์ผ€ ํ•œ๋‹ค.

npx create-react-app first-react

1: Nodejs ์„ค์น˜ํ•˜๊ธฐ

 

node -v ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด nodejs๊ฐ€ ์„ค์น˜ ํ™•์ธ

  • npm : Node Package Manager. NodeJS๋กœ ๊ฐœ๋ฐœ๋œ ๋ชจ๋“ˆ๋“ค์„ ์„ค์น˜ํ•˜๊ณ  ๊ด€๋ฆฌํ•ด์ฃผ๋Š” ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ ธ
  • nodeJS๋กœ ๋งŒ๋“ค์–ด์ง„ ์œ ์šฉํ•œ ๋ชจ๋“ˆ๋“ค์„ ๊ฐ€์ ธ๋‹ค ์“ฐ๊ณ  ๊ด€๋ฆฌ

 

2: ํ”„๋กœ์ ํŠธ ์‹œ์ž‘ :

๋ฆฌ์•กํŠธ์— ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์ž๋™์œผ๋กœ ์„ค์น˜ํ•ด์ฃผ๋Š” ๋ช…๋ น์–ด ์ž…๋ ฅ

  1. ํ”„๋กœ์ ํŠธ๋ฅผ ์„ค์น˜ํ•˜๊ณ ์‹ถ์€ ๊ฒฝ๋กœ์—์„œ
  2. npx create-react-app ํด๋”๋ช… ์„ํ†ตํ•ด ์„ค์น˜์˜ˆ๋ฅผ ๋“ค๋ฉด,
    npx create-react-app todoApp
  3. Happy hacking ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜์˜ค๋ฉด ์„ฑ๊ณต

 npx create-react-app first-react
Need to install the following packages:
  create-react-app
Ok to proceed? (y) y

Creating a new React app in C:\Users\User\Project\first-react.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1377 packages in 2m

179 packages are looking for funding
  run `npm fund` for details        

Initialized a git repository.

Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated

added 39 packages in 11s

179 packages are looking for funding
  run `npm fund` for details
Removing template package using npm...


removed 1 package, and audited 1416 packages in 5s

179 packages are looking for funding
  run `npm fund` for details

6 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

Created git commit.

Success! Created first-react at C:\Users\User\progect\first-react
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd first-react
  npm start

Happy hacking!

 

 

 

 

public/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>
 

 

    <div id="root"></div>

3: SPA : ๋ฆฌ์•กํŠธ ์•ˆ์—๋Š” HTML ํŽ˜์ด์ง€๋„ ๋‹จ ํ•˜๋‚˜, ํƒœ๊ทธ๋„ ๋‹จ ํ•˜๋‚˜์ด๋‹ค.

Single Page Application์˜ ์ค€๋ง ์ฆ‰ ํŽ˜์ด์ง€๊ฐ€ ํ•˜๋‚˜๋ผ๋Š” ๋œป

ํ•˜๋‚˜์˜ ํŽ˜์ด์ง€ ์•ˆ์—์„œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๊ฐ€ ํ•„์š”ํ•œ ํŽ˜์ด์ง€๋‚˜ ์ •๋ณด๋งŒ ๋™์ ์œผ๋กœ ๊ทธ๋ ค์ค€๋‹ค. ์ฆ‰, ์ƒˆ ํŽ˜์ด์ง€๋กœ ๋„˜์–ด๊ฐˆ๋•Œ๋งˆ๋‹ค ์„œ๋ฒ„์—์„œ HTML CSS JS ์†Œ์Šค๋ฅผ ๊ฐ€์ ธ์˜ฌ ํ•„์š”๊ฐ€ ์—†์–ด ์ƒˆ๋กœ๊ณ ์นจ์ด ํ•„์š”์—†๋‹ค. ๋”ฐ๋ผ์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ฌผํ๋ฅด๋“ฏ ๋Š๊น€์—†๋Š” ์›น์•ฑ ๊ฒฝํ—˜

๋‹จ์ ์€ ์ฒ˜์Œ์— ํ•„์š”ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ๋‹ค ๊ฐ€์ ธ์™€์•ผ ํ•ด์„œ ์ดˆ๊ธฐ ๊ตฌ๋™ ์†๋„๊ฐ€ ๋А๋ฆฌ๋‹ค.

 

 

src/index.js : HTML๊ณผ JS๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ์—ฐ๊ฒฐ๊ณ ๋ฆฌ๋ธŒ๋ฆฟ์ง€ ์ฆ‰, html ํŒŒ์ผ์— ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์–น์–ด์ฃผ๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•จ

index.js ์—ญํ• ์€ index.html๊ณผ App.js๋ฅผ ์—ฐ๊ฒฐ

์›ฌ๋งŒํ•ด์„œ๋Š” ๊ฑด๋“œ๋ฆด ์ผ์ด ์—†๋Š” ํŒŒ์ผ

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

// 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();

ReactDOM.render์€ ์„ ํƒํ•œ html ํƒœ๊ทธ์— react๋ฅผ ๊ทธ๋ ค์ค€๋‹ค(์„ ํƒํ•œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์–น๋Š”๋‹ค)

์ฆ‰, ์ฝ”๋“œ๋Š”

root๊ฐ€ id์ธ ํƒœ๊ทธ๋ฃฐ ๋“ค๊ณ  ์™€์„œ, ๊ฑฐ๊ธฐ๋‹ค App์ด๋ผ๋Š” react ์ปดํฌ๋„ŒํŠธ๋ฅผ ์–น์–ด์ค€๋‹ค๊ณ  ํ•ด์„ํ•  ์ˆ˜ ์žˆ๋‹ค.

์•ž์œผ๋กœ ๋ฆฌ์•กํŠธ ์ž‘์—…์€ ๋ชจ๋‘ App.js์— ๋“ค์–ด๊ฐ€๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค.

 

 

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));

์„ ํƒํ•œ html ํƒœ๊ทธ์— react๋ฅผ ๊ทธ๋ ค์คŒ

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

reportWebVitals();

 

 

src/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;

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;

 

4: npm start

์š” ํ™”๋ฉด์ด ๋ณด์ด๋ฉด ์„ฑ๊ณต~~~

 

App.js ๋ฅผ ์ด๋ ‡๊ฒŒ ๋ฐ”๊พธ๋ฉด...

import "./App.css";

function App() {
  return (
    <div className="App">
      <header className="App-header">์•ˆ๋…•ํ•˜์„ธ์š” ๋ฆฌ์•กํŠธ ์ž…๋‹ˆ๋‹ค.</header>
    </div>
  );
}

export default App;

์ž˜ ๋ณ€๊ฒฝ๋œ ๋ชจ์Šต

C:\Users\User\gitprogect\bokkieProject\first-react\src\App.css ์† ๋‚ด์šฉ์€ ์•ž์œผ๋กœ ์“ธ ์ผ์ด ์—†๋‹ค๋ฉด ์ง€์›Œ์ฃผ๋ฉด ๋œ๋‹ค.

728x90

'Javascript > React' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[React] fontawesome ๋ฆฌ์•กํŠธ๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ  (0) 2022.12.26
[React] ๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ์™€ ๊ด€๋ จ Hooks ์ •๋ฆฌ  (0) 2022.12.14
[๋ฆฌ์•กํŠธ] ์ปดํฌ๋„ŒํŠธ ๋‹จ์ถ•ํ‚ค ๊นกํŒจ rafce  (0) 2022.05.23
[React] index.html ์— ๋ฆฌ์•กํŠธ์™€ ๋ฐ”๋ฒจ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ  (0) 2022.04.23
    'Javascript/React' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • [React] fontawesome ๋ฆฌ์•กํŠธ๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ
    • [React] ๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ์™€ ๊ด€๋ จ Hooks ์ •๋ฆฌ
    • [๋ฆฌ์•กํŠธ] ์ปดํฌ๋„ŒํŠธ ๋‹จ์ถ•ํ‚ค ๊นกํŒจ rafce
    • [React] index.html ์— ๋ฆฌ์•กํŠธ์™€ ๋ฐ”๋ฒจ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
    Rainbow๐ŸŒˆCoder
    Rainbow๐ŸŒˆCoder
    ๋ชฐ๋ผ๋„ ๊ฒฐ๊ตญ์€ ์•„๋Š” ๊ฐœ๋ฐœ์ž, ๊ทธ๋Ÿฐ ์‚ฌ๋žŒ์ด ๋˜๊ธฐ ์œ„ํ•œ ๋งค์ผ์˜ ํ•œ๊ฑธ์Œ

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”