๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

๐Ÿ“— React15

[React] ๋ฆฌ์•กํŠธ์˜ Hooks ์˜ˆ์ œ๋กœ ์ •๋ณตํ•˜๊ธฐ React Hooks functional component์—์„œ state๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ฆ class component, componentdidMount, render() ํ•  ํ•„์š”๊ฐ€ ์—†์Œ -> ํ•˜๋‚˜์˜ funciton ์ด ๋จ ์ด๊ฒƒ์€ ํ•จ์ˆ˜ํ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ด๋ผ๋Š” ๋œป์ด๊ธฐ๋„ ํ•จ! recompose + react = ๋ฆฌ์•กํŠธ ํ›…! ๐Ÿ“ŒClass component๋ฅผ ์ด์šฉํ•œ react (๊ธฐ์กด ๋ฐฉ์‹) ๋ฒ„ํŠผ ํด๋ฆญ์‹œ count ๊ฐ€ ํ•˜๋‚˜์”ฉ ์ฆ๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ import React from "react"; import './App.css'; class App extends React.Component{ state = { count: 0 }; modify = (n) => { const { count } = this.state; // .. 2021. 3. 18.
[React ] React Router๋ฅผ ์ด์šฉํ•˜์—ฌ component๊ฐ„์— props ๋„˜๊ฒจ์ฃผ๊ธฐ ( (Link & props) react ๋ฅผ ์ด์šฉํ•˜์—ฌ navigation bar๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์–ด๋ณด์ž navigation bar๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋ฉด์„œ reactd์—์„œ๋Š” ํŽ˜์ด์ง€ ๊ฐ„์— data๋ฅผ ์–ด๋–ป๊ฒŒ ์—ฐ๊ฒฐํ•˜๊ณ  ๊ณต์œ ํ•˜๋Š”์ง€ ๊ณต๋ถ€ํ•ด ๋ณผ ๊ฒƒ์ด๋‹ค. 1) react-router-dom ์„ค์น˜ * npm ์œผ๋กœ ์„ค์น˜ npm install react-router-dom * yarn ์œผ๋กœ ์„ค์น˜ yarn add react-router-dom 2) Routes ํด๋” ์ƒ์„ฑ routes ํด๋”์—๋Š” ๋‚ด๊ฐ€ ๋งŒ๋“ค๊ณ  ์‹ถ์€(์ด๋™ํ• ) ํŽ˜์ด์ง€ ๊ฐœ์ˆ˜๋งŒํผ ๋งŒ๋“ ๋‹ค routes์— 3๊ฐœ์˜ ํŽ˜์ด์ง€ ์ƒ์„ฑ - Home.js : ๋ฉ”์ธ ์˜ํ™”์„ค๋ช… (์˜ํ™”๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ํŽ˜์ด์ง€ ) - About.js : ์›นํŽ˜์ด์ง€ ์†Œ๊ฐœ๊ธ€ (์ž๊ธฐ์†Œ๊ฐœ ๋„ฃ์„ ์˜ˆ์ •) - Datail.js : ์˜ํ™” ์ƒ์„ธ ์„ค๋ช… (์˜ํ™” ํด๋ฆญ์‹œ ์ƒ์„ธ์„ค๋ช… ํŽ˜.. 2021. 3. 18.
[React] ํ”„๋กœ์ ํŠธ GitHub Pages ๋ฐฐํฌํ•˜๊ธฐ + Axios ๋ฅผํ†ตํ•ด json data ๊ฐ€์ ธ์˜ค๊ธฐ AXIOS fetch์œ„์— ์žˆ๋Š” ์ž‘์€ layer // asios ์„ค์น˜ npm i axios data fetchํ•˜๊ธฐ ๋ณดํ†ต Fetch ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ data๋ฅผ load ํ•˜๋””๋งŒ asios๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์ž class App extends React.Component{ state={ isLoading: true, movies:[] }; getMovies = async() =>{ const movies = await axios.get("https://yts-proxy.now.sh/list_movies.json"); console.log(movies); }; componentDidMount(){ this.getMovies(); } render(){ const {isLoading} = this.state; return ( {.. 2021. 3. 17.
[React] setState and Lifecycle function component //function component function App() { return ( ) ; } return ํ•œ ๊ฐ’์„ screen ์— ํ‘œ์‹œ class component React class component ์—์„œ ๊ฐ€์ ธ์˜จ APP component //App์€ react component class App extends React.Component{ render( return () ) ; } React component์—์„œ ํ™•์žฅํ•œ ๊ฒƒ๋“ค์„ screen์— ํ‘œ์‹œ react๊ฐ€ render() ๋ฉ”์„œ๋“œ๋ฅผ ์ž๋™์œผ๋กœ ์‹คํ–‰ class component๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œต state : object ,data๋ฅผ ๋„ฃ์„ ๊ณต๊ฐ„์ด ์žˆ์Œ data๋Š” ํ•ญ์ƒ ๋ณ€ํ•˜๊ธฐ ๋•Œ๋ฌธ์— state์™€ ๊ฐ™์€ ๊ณต๊ฐ„ ์ด ํ•„์š” sta.. 2021. 3. 16.
[ React ] JSX ์ดํ•ดํ•˜๊ธฐ & Proptypes component HTML ์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ component๋ฅผ ์‚ฌ์šฉํ•ด์„œ ReactDOM.render( , document.getElementById('root') ); JSX javascrtip ์•ˆ์˜ HTML Component๋ฅผ ๋งŒ๋“ค๊ณ  ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ javascript + HTML์˜ ์กฐํ•ฉ React ์˜ component ์ƒ์„ฑ ํ๋ฆ„ react application์€ ์˜ค์ง ํ•˜๋‚˜์˜ component๋งŒ rendering ๋”ฐ๋ผ์„œ -> ๋ชจ๋“  ๊ฒƒ์€ apapplication(API) ์•ˆ์— ๋“ค์–ด๊ฐ€์•ผํ•จ ๊ตฌํ˜„ํ•˜๊ณ ์‹ถ์€ component ํŒŒ์ผ๋“ค์„ ๋งŒ๋“ค์–ด API.js์— import ํ•˜๊ณ  API.js๋ฅผ index ์— ๋ Œ๋”๋งํ•˜๋Š” ๋ฐฉ์‹ REACT์˜ ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ component ๋ถˆ๋Ÿฌ์˜ค๊ธฐ โ– ์ •์ ๋ฐ์ดํ„ฐ ์„ค์ • (์ง์ ‘ ๋„ฃ์–ด์ค€ ๋ฐ์ด.. 2021. 3. 16.
React ๋ฆฌ์•กํŠธ๋ž€, ๋ฆฌ์•กํŠธ ์ž‘์—…ํ™˜๊ฒฝ ์„ค์ • ์‚ฌ๋žŒ๋“ค์ด ์ข‹์•„ํ•˜๊ณ , ์ธ๊ธฐ์žˆ๊ณ  , ๊ฐ„ํŽธํ•œ ํ”„๋ ˆ์ž„์›Œํฌ! ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ธฐ๋ฐ˜์ด๊ธฐ๋•Œ๋ฌธ์— ๋ฐฐ์šฐ๋Š”๋ฐ๋„ ๋ถ€๋‹ด์ด ์—†๋‹ค. ๋ฆฌ์•กํŠธ๋ฅผ ์ตํ˜€๋ณด๊ณ  ์ง์ ‘ ์‚ฌ์šฉํ•ด๋ณด๊ธฐ ์œ„ํ•ด ๋…ธ๋งˆ๋“œ์ฝ”๋”์˜ ReactJS ๋กœ ์˜ํ™” ์›น์„œ๋น„์Šค ๋งŒ๋“ค๊ธฐ๋ฅผ ํ•ด๋ณผ ์˜ˆ์ •! ์˜ค์˜ˆ~ ์›๋ž˜ ๋ฆฌ์•กํŠธ๋ฅผ ์›น๋ธŒ๋ผ์šฐ์ €์—์„œ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ธŒ๋ผ์šฐ์ €๋Š” ๋ฆฌ์•กํŠธ ์ฝ”๋“œ๋ฅผ ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜์ง€ ๋ชปํ•˜๊ธฐ(?) ๋•Œ๋ฌธ์— ์›์‹œ์ฝ”๋“œ๋กœ ๋ณ€๊ฒฝํ•ด์•ผ ํ•จ webpack , Babel ๋‹ค์šด๋กœ๋“œ -> ๋ฆฌ์•กํŠธ ์ฝ”๋“œ ์ปดํŒŒ์ผ ๊ณผ์ •์„ ๊ฑฐ์ณ์•ผ ํ•จ ํ•˜์ง€๋งŒ, create react app ํ•˜๋‚˜์˜ ๋ช…๋ น์„ ์‹คํ–‰ํ•ด์„œ React Web App ์„ ์‹คํ–‰ 1) createreact app์„ ํ†ตํ•ด ๋ฆฌ์•กํŠธ ํ™˜๊ฒฝ ๊ตฌ์„ฑ ex) ํ•œ๋‹จ๊ณ„ ๋ฐ– A ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ์ƒ์„ฑ -> movie_app ์ด๋ผ๋Š” ํ”„๋กœ์ ํŠธ ํด๋” ์ƒ์„ฑ //npx create-react-app.. 2021. 3. 16.
๋ฐ˜์‘ํ˜•