๋ฐ˜์‘ํ˜•

Frontend/Angular vs React 6

Angular vs React | ์ƒ๋ช…์ฃผ๊ธฐ ๋ฉ”์„œ๋“œ์— ๋Œ€ํ•ด์„œ

๊ณตํ†ต์  1. ์ดˆ๊ธฐํ™” ๋‹จ๊ณ„ ๋‘ ํ”„๋ ˆ์ž„์›Œํฌ ๋ชจ๋‘ ์ปดํฌ๋„ŒํŠธ ์ดˆ๊ธฐํ™” ๋‹จ๊ณ„์—์„œ ํŠน์ • ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. Angular : ngOnInit React : constructor, componentDidMount 2. ์†Œ๋ฉธ ๋‹จ๊ณ„ ๋‘ ํ”„๋ ˆ์ž„์›Œํฌ ๋ชจ๋‘ ์ปดํฌ๋„ŒํŠธ ์†Œ๋ฉธ ๋‹จ๊ณ„์—์„œ ํŠน์ • ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. Angular : ngOnDestroy React : componentWillUnmount ์ฐจ์ด์  1. ๋ณ€๊ฒฝ ๊ฐ์ง€ (Change Detection) Angular ๋ณ€๊ฒฝ ๊ฐ์ง€ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ๋‚ด๋ถ€์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ๋‚˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค Angular๋Š” ์ปดํฌ๋„ŒํŠธ์˜ ๋ทฐ๋ฅผ ์—…๋ฐ์ดํŠธํ•œ๋‹ค. ex) ngOnChanges, ngDoCheck React Virtual DOM์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ณ€๊ฒฝ ๊ฐ์ง€๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค. ์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ๋‚˜ ์†์„ฑ..

Angular vs React | ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ง„์ž…์ ์— ๋Œ€ํ•ด์„œ

Angular์˜ index.ts Angular ํ”„๋กœ์ ํŠธ์—์„œ index.ts ํŒŒ์ผ์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ง„์ž…์  (entry point)๋กœ์„œ ์‚ฌ์šฉ๋œ๋‹ค. Angular ๋ชจ๋“ˆ์„ ๋กœ๋“œํ•˜๊ณ , ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. platformBrowserDynamic() ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ €์— ๋™์ ์œผ๋กœ Angular ํ”„๋กœ์ ํŠธ๋ฅผ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํ•˜๊ณ , AppModule์„ ๋กœ๋“œํ•œ๋‹ค. // index.ts import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; platformBrowserDynamic().bootstrapModule(AppModule) .catc..

Angular vs React | ๋™์  ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ์— ๋Œ€ํ•ด์„œ

Angular์˜ {{ }} Interpolation์€ ๋ณด๊ฐ„์ด๋ผ๊ณ ๋„ ํ•˜๋ฉฐ, ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”์ธ๋”ฉ ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. '{{ }}' ๊ตฌ๋ฌธ์œผ๋กœ ๋™์ ์œผ๋กœ ๋ฐ”์ธ๋”ฉํ•  ๊ตฌ๋ฌธ์„ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค. // app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` {{pageTitle}} Welcome to {{frameworkName}}! `, styleUrls: ['./app.component.css'] }) export class AppComponent { pageTitle: string = 'Angular Interpolation Example'; frameworkName: string = 'An..

Angular vs React | ์ž์‹ ์ปดํฌ๋„ŒํŠธ๋กœ์˜ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ์— ๋Œ€ํ•ด์„œ

Angular์˜ @Input ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์—์„œ ์ž์‹ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•  ๋•Œ ์‚ฌ์šฉ ์ž์‹ ์ปดํฌ๋„ŒํŠธ์˜ ์†์ •์„ ์ •์˜ ํ•˜๊ณ , ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์—์„œ ๊ฐ’์„ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์—์„œ [childProperty]="parentValue"์™€ ๊ฐ™์ด ์†์„ฑ์„ ์„ค์ •ํ•˜์—ฌ ์ž์‹ ์ปดํฌ๋„ŒํŠธ์— ๊ฐ’์„ ์ „๋‹ฌํ•œ๋‹ค. // parent.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-parent', template: ` `, }) export class ParentComponent { parentValue = '๋ถ€๋ชจ์—์„œ ์ „๋‹ฌํ•œ ๊ฐ’'; } // child.component.ts import { Component, Input }..

Angular vs React | ๊ฐ€์ƒ DOM์— ๋Œ€ํ•ด์„œ

์‹ค์ œ DOM Document Object Model ์›น ํŽ˜์ด์ง€์˜ ๊ตฌ์กฐ๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ํŠธ๋ฆฌ ๊ตฌ์กฐ HTML ์š”์†Œ๋“ค์„ ๊ฐ์ฒด๋กœ ํ‘œํ˜„ ๊ฐ€์ƒ DOM ์‹ค์ œ DOM์˜ ๊ฐ€๋ฒผ์šด ๋ณต์ œ๋ณธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ํ˜„์žฌ ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋ƒ„ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅ๋จ ์‹ค์ œ DOM๊ณผ ๋™๊ธฐํ™” ๋จ UI ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ, ๋จผ์ € ๊ฐ€์ƒ DOM์—์„œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๊ณ„์‚ฐ ํ•œ ๋‹ค์Œ, ์‹ค์ œ DOM์— ์ ์šฉ Angular ์‹ค์ œ DOM์š”์†Œ๋ฅผ ์ง์ ‘ ์กฐ์ž‘ํ•˜๋ฉฐ, ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๊ฐ์ง€ -> ์—…๋ฐ์ดํŠธ ๋ณ€๊ฒฝ๊ฐ์ง€๋Š” Angular ํ”„๋ ˆ์ž„์›Œํฌ ๋‚ด๋ถ€์—์„œ ์ฒ˜๋ฆฌ๋จ ngOnInit, ngAfterViewInit, ngOnDestroy ๋“ฑ๋“ฑ.. React ๊ฐ€์ƒ DOM์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ฑ๋Šฅ ์ตœ์ ํ™” ์‹ค์ œ UI ์—…๋ฐ์ดํŠธ ์‹œ ๊ฐ€์ƒ DOM์„ ์กฐ์ž‘ ์ด์ „ ๊ฐ€์ƒ DOM๊ณผ ์ƒํƒœ๋ฅผ ๋น„๊ตํ•˜์—ฌ ๋ณ€๊ฒฝ๋œ ๋ถ€๋ถ„์„ ์‹ค์ œ DOM์— ์ ์šฉ DOM ..

๋ฐ˜์‘ํ˜•