๋ฐ˜์‘ํ˜•

๐ŸŸฉ Frontend-HTML & CSS & +JS 42

[JS] ์นด์นด์˜คํ†ก ๋กœ๊ทธ์ธ/๋กœ๊ทธ์•„์›ƒ/ํƒˆํ‡ดํ•˜๊ธฐ ๋ฐฉ๋ฒ• ๋ฐ html ํŒŒ์ผ (์ฝ”๋“œ์žˆ์Œ)

1.์นด์นด์˜ค ๊ฐœ๋ฐœ์ž ์‚ฌ์ดํŠธ์—์„œ web์šฉ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋งŒ๋“ฌ์‚ฌ์ดํŠธ ๋„๋ฉ”์ธ์€ ๋กœ์ปฌ์ด๋ผ ๋กœ์ปฌ๋กœ ์ง€์ • 2. ๋“ฑ๋กํ•˜๋Ÿฌ๊ฐ€๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ, ๋กœ๊ทธ์ธ ์„ฑ๊ณตํ›„ ๊ฐˆ ๊ณณ ์ง€์ •   3. ์•„๋ž˜์˜ ๋™์˜ํ•ญ๋ชฉ ๋„ฃ์Œ(๋”ํ•˜๋ ค๋ฉด ๋น„์ฆˆ๋‹ˆ์Šค ๊ณ„์ • ๋ณ€ํ™˜ ํ•„์š”)    4. js ์•ฑํ‚ค ๋ณต์‚ฌ ํ•ด๋†“๊ณ  html ๋‘˜ ๋‹ค์— ๋„ฃ์Œ         | ํด๋”๊ตฌ์„ฑ  | index.html (๋กœ๊ทธ์ธ ํ•  ๊ณณ ์ฝ”๋“œ) ํ•ด๋‹น Live Demo๋Š” ํ…Œ์ŠคํŠธ์šฉ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜๋“œ์‹œ ์†Œ์Šค ์ฝ”๋“œ์— '๋ณธ์ธ API ํ‚ค'๋ฅผ ๋„ฃ์–ด์•ผ ์ œ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.   | kakao_login.html (๋กœ๊ทธ์ธ ํ•œ ํ›„ redirection ๋  ๊ณณ ์ฝ”๋“œ) ๋กœ๋”ฉ ์ค‘... ๋กœ๊ทธ์•„์›ƒ | ํƒˆํ‡ด    | ํŒŒ์ผ ๋‹ค์šด

contextํŒŒ์ผ์˜ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์™€์„œ ์—ฌ๋Ÿฌ div ๋ชฉ๋ก๋งŒ๋“ค์–ด ์“ฐ๊ธฐ (UseContext / map/slice)

๋งŒ์•ฝ ๋‚ด๊ฐ€(AllContext.jsx) ํŒŒ์ผ์— ์žˆ๋Š”๊ณต์ง€์‚ฌํ•ญ ์˜ ์ œ๋ชฉ, ์—ฐ๋„๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ  ์‹ถ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ์ด๋‹ค  | Main.jsximport React, { useContext, useState } from "react"; //useContext ๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ์œ„ํ•œ ์ฝ”๋“œimport { Link } from 'react-router-dom'; //์ด๊ฑด ๋งํฌ๋ฅผ ๋‹ฌ๊ธฐ์œ„ํ•œ์ฝ”๋“œ (a href๊ฐ™์€ ์ฝ”๋“œ)import AllContext from './AllContext'; // context๊ฐ€ ์žˆ๋Š” ํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ค๋Š” ์ฝ”๋“œfunction Main() { return( ์ด {noticeData.length}๊ฑด // ๋ช‡ ๊ฑด์ธ์ง€ contextํŒŒ์ผ์•ˆ์˜ ..

๋ฆฌ์•กํŠธ ์•„์ด์ฝ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์“ฐ๊ธฐ (๋ถ€ํŠธ์ŠคํŠธ๋žฉ/yarn/npm)

| ์„ค์น˜ https://react-icons.github.io/react-icons/ React Icons react-icons.github.iohttps://icons.getbootstrap.com/  ์ด ์‚ฌ์ดํŠธ์—์„œ ๋ฏธ๋ฆฌ ๋ณผ ์ˆ˜ ์žˆ๊ณ  ์•„๋ž˜ code๋กœ ์„ค์น˜ //yarn ์šฉ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌyarn add react-bootstrap bootstrapyarn add react-icons//์ผ๋ฐ˜ ์šฉ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌnpm install react-bootstrap-icons --savenpm install react-icons --save // npm   | ๊ธฐ๋ณธ ์‚ฌ์šฉ ์˜ˆimport { MdLogin, MdOutlineLogout, MdOutlineAccountCircle } from "react-icons/md"; ์‚ฌ์šฉ..

๋ฆฌ์•กํŠธ์— ์Šคํƒ€์ผ ์—ฌ๋Ÿฌ๊ฐœ ์ฃผ๊ธฐ (classNames ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)

1. ์•„๋ž˜์™€ ๊ฐ™์ด classNames๋ฅผ ์„ค์น˜ํ•จnpm install classnames ํ˜น์€ yarn add classnames   2. ์ƒ๋‹จ์— import , ์„ค์น˜ํ›„์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๋‘๊ฐ€์ง€๋ฅผ ๋™์‹œ์— ๋„ฃ์„ ์ˆ˜ ์žˆ์Œ import classNames from 'classnames';      --- ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”, ๋‹ค๋ฅธ ๋ฐฉ๋ฒ• : ํ…œํ”Œ๋ฆฟ ๋ฌธ์ž์—ด ์‚ฌ์šฉ ---

๋ฆฌ์•กํŠธ์— swiper ์“ฐ๋Š” ์˜ˆ์ œ (dom ๋ฒ„์ „ ์˜ค๋ฅ˜ํ•ด๊ฒฐ๋ฒ•) (React swiper)

| ์„ค์น˜ ๋ฐ ๊ธฐ๋ณธ ์‚ฌ์šฉ ์˜ˆhttps://swiperjs.com/react#use-swiper-slide Swiper - The Most Modern Mobile Touch SliderSwiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.swiperjs.com 1. React์™€ React-DOM ํŒจํ‚ค์ง€๋ฅผ ์•„๋ž˜ ๋ฒ„์ „์œผ๋กœ ์„ค์น˜ npm install react@18 react-dom@18 โ€ป ๋งŒ์•ฝ, ์ด์ „ ๋ฒ„์ „์ด ๋‚ฎ๊ฑฐ๋‚˜ ๋†’์•„์„œ ์‚ฌ์šฉ์ด ์•ˆ๋œ๋‹ค๋ฉด, ์•„๋ž˜ ์ฝ”๋“œ๋กœ ์‚ญ์ œํ›„ ์œ„ ์ฝ”๋“œ๋กœ ๋‹ค์‹œ ์„ค์น˜npm uninstall react react-dom  2. Swiper ์„ค์น˜..

Codepen ์—์„œ React ์‹คํ–‰ํ•˜๊ธฐ

๐Ÿ“ŒReactDOM / React ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€- Settings > JavaScript ํƒญ์œผ๋กœ ์ด๋™ํ•˜์—ฌ ReactDOM , React ๋ฅผ External Scripts์— ์ถ”๊ฐ€- Settings > JavaScript ํƒญ์œผ๋กœ ์ด๋™ํ•˜์—ฌ ReactDOM์„ External Scripts์— ์ถ”๊ฐ€โš ๏ธ ๊ฒ€์ƒ‰ํ•ด์„œ ๋‚˜์˜ค๋Š” CDN์„ ๋„ฃ๊ณ , 19.0.0 ๋ฒ„์ „์ด ์•„๋‹ˆ๋ผ 18.2.0์œผ๋กœ ์ง์ ‘ ์ˆ˜์ •ํ•ด์•ผ ์ž˜ ๋™์ž‘ํ•จ  ๐Ÿ“ŒBabel ๋ณ€๊ฒฝ- Settings > JavaScript ํƒญ์œผ๋กœ ์ด๋™ํ•˜์—ฌ JavaScript Preprocessor ๋ฅผ  Babel ์œผ๋กœ๋ณ€๊ฒฝ      ๐Ÿ“Œ codepen ์œผ๋กœ ์‹คํ–‰ํ•˜๋Š” ์˜ˆ์‹œ See the Pen Untitled by galaxy_star (@fold6) on CodePen.

React ์˜ˆ์ œ ํŒŒ์ผ ์—ฌ๋Š”๋ฒ• (๋ช…๋ น์–ด)

1. ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™     ํ„ฐ๋ฏธ๋„์„ ์—ด๊ณ  ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™:     cd REACT-TODO-APP 2. ํŒจํ‚ค์ง€ ์„ค์น˜ (๋˜๋Š” yarn.lock ํŒŒ์ผ ๋Œ€์‹  package-lock.json ํŒŒ์ผ์ด ์žˆ๋Š” ๊ฒฝ์šฐ npm install)    ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜:     yarn install     ๋˜๋Š”     npm install 3. ๊ฐœ๋ฐœ ์„œ๋ฒ„ ์‹คํ–‰     ์„œ๋ฒ„๋ฅผ ์‹คํ–‰:     yarn start     ๋˜๋Š”     npm start

React Router๋ฅผ ํ™œ์šฉํ•œ ๋ผ์šฐํŒ… ๋ฐ ์ฟผ๋ฆฌ ์ฒ˜๋ฆฌ

| react-router-dom๋ฆฌ์•กํŠธ์˜ ๋ผ์šฐํŒ…์„ ์œ„ํ•œ ํ•ต์‹ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.(์•„๋ž˜๋Š” ๋ผ์šฐํŒ… ์„ค์ •, ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ์ฟผ๋ฆฌ ํ™œ์šฉ, ์„œ๋ธŒ๋ผ์šฐํŠธ ๊ตฌ์„ฑ, ๊ทธ๋ฆฌ๊ณ  history ๊ฐ์ฒด๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•)  | ์„ค์น˜ ๋ฐ ๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•1. react-router-dom ์„ค์น˜yarn add react-router-dom@5 - ํŠน์ • ์ฃผ์†Œ์™€ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์—ฐ๊ฒฐํ•  ๋• Route ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉ - ์ฃผ์†Œ์ด๋™์€ Link ์ปดํฌ๋„ŒํŠธ๋กœ ์ฒ˜๋ฆฌimport { Route, Link } from 'react-router-dom';๋ฌธ์ž    | ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ์ฟผ๋ฆฌํŽ˜์ด์ง€ ์ฃผ์†Œ ์ •์˜ ์‹œ ์œ ๋™์ ์ธ ๊ฐ’์„ ์ „๋‹ฌํ•ด์•ผ ํ•  ๋•Œ๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๋‚˜ ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•จ.ํŒŒ๋ผ๋ฏธํ„ฐ: ํŠน์ • ID๋‚˜ ์ด๋ฆ„ ์กฐํšŒ ์‹œ ์‚ฌ์šฉํ•จ.์˜ˆ: /profile/apple์ฟผ๋ฆฌ: ๊ฒ€์ƒ‰ ํ‚ค์›Œ๋“œ๋‚˜ ์˜ต์…˜ ์ „๋‹ฌ ์‹œ ์‚ฌ์šฉํ•จ.์˜ˆ: /..

React ์ˆซ์ž ์˜ฌ๋ผ๊ฐ€๋Š” ์ปดํฌ๋„ŒํŠธ ๋งŒ๋“ค๊ธฐ (useState)

| App.jsimport React from 'react';import Counter from './component/counter';import Input from './component/input';import './App.css';function App() { return ( {/* */} );}export default App;   | counter.jsximport React,{useState} from "react";// ๋ฆฌ์•กํŠธ ํŒจํ‚ค์ง€์—์„œ useState๋ผ๋Š” hooks๋ฅผ ๋ถˆ๋Ÿฌ์˜ดfunction Counter(){ const[number,setNumber] = useState(0); //number์€ ์ดˆ๊ธฐ๊ฐ’ 0์ด ํ• ๋‹น //number์— ๊ฐ’์„ ๋ฐ”๊พผ๋‹ค ์ƒํƒœ๊ฐ’..

๋ฐ˜์‘ํ˜•