Frontend/Angular vs React

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

์ด์ œํฌ 2023. 11. 15. 19:00


Angular์˜ {{  }}

  • Interpolation์€ ๋ณด๊ฐ„์ด๋ผ๊ณ ๋„ ํ•˜๋ฉฐ, ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”์ธ๋”ฉ ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • '{{  }}' ๊ตฌ๋ฌธ์œผ๋กœ ๋™์ ์œผ๋กœ ๋ฐ”์ธ๋”ฉํ•  ๊ตฌ๋ฌธ์„ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.
// app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <div>
      <h1>{{pageTitle}}</h1>
      <p>Welcome to {{frameworkName}}!</p>
    </div>
  `,
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  pageTitle: string = 'Angular Interpolation Example';
  frameworkName: string = 'Angular';
}

React์˜ {  }

  • JSX (JavaScript XML)๋Š” ์ž๋ฐ” ์Šคํฌ๋ฆฝํŠธ์˜ ํ™•์žฅ ๋ฌธ๋ฒ•์œผ๋กœ, React์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ฃผ์š” ๋ฌธ๋ฒ•์ž…๋‹ˆ๋‹ค.
  • JSX์—์„œ ์ค‘๊ด„ํ˜ธ '{ }'๋ฅผ ์‚ฌ์šฉํ•ด JavaScript ํ‘œํ˜„์‹์„ ๊ฐ์‹ธ๋Š” ๊ฒƒ์œผ๋กœ ๋™์  ๋ฐ์ดํ„ฐ ํŒŒ์ธ๋”ฉ์„ ํ‘œํ˜„ํ•œ๋‹ค.
  • JavaScript ํ‘œํ˜„์‹์„ ์ค‘๊ด„ํ˜ธ '{ }' ์•ˆ์— ํฌํ•จ์‹œํ‚ค๋ฉด ํ•ด๋‹น ๋ถ€๋ถ„์„ ๋™์ ์œผ๋กœ ๊ณ„์‚ฐํ•˜๊ณ  ํ‘œํ˜„ํ•œ๋‹ค.
import React from 'react';

const App = () => {
  const message = 'Hello, JSX!';

  return (
    <div>
      <h1>{message}</h1>
      <p>{2 + 2}</p>
    </div>
  );
};

export default App;
๋ฐ˜์‘ํ˜•