13. 컴포넌트 분리 저장

  • 프로젝트 링크open in new window

  • 컴포넌트 분리 저장

    src/components/Header.tsx
    import reactImg from '../assets/react-core-concepts.png';
    
    const reactDescriptions = ['Fundamental', 'Crucial', 'Core'];
    
    function genRandomInt(max: number): number {
      return Math.floor(Math.random() * (max + 1))
    }
    
    function Header() {
      const description = reactDescriptions[genRandomInt(reactDescriptions.length - 1)]
      return (
        <header>
          <img src={reactImg} alt="React logo" />
          <h1>React Essentials</h1>
          <p>
            {description}
          </p>
        </header>
      );
    }
    
    export default Header;