TypeScript學習

因為到處的React教學幾乎都夾雜TypeScript,所以決定還是趕快來學一下,不然要看教學也看不懂🤣
以下列出一些覺得還不錯的教學文章。
microsoft/TypeScript-React-Starter
Getting started with React and TypeScript

Using React Functional Components with Hooks in TypeScript
教怎麼寫functional component,還有hooks
React with TypeScript: Best Practices
React with TypeScript: Components as Function Declarations vs. Function Expressions
React Children with TypeScript
React with Typescript

React TypeScript Cheatsheets | React TypeScript Cheatsheets
typescript-cheatsheets/react: Cheatsheets for experienced React developers getting started with TypeScript

TypeScript for React developers in 2020
電子書:
TypeScript Deep Dive

react.js PropTypes

導入這樣導:

import PropTypes from 'prop-types'; // ES6

設定這樣設:

CuteLuna.propTypes = {
  order: PropTypes.arrayOf(PropTypes.string),
};

各種類型:

// array of string
order: PropTypes.arrayOf(PropTypes.string),
MyComponent.propTypes = {
  items: PropTypes.arrayOf(
    PropTypes.shape({
      code: PropTypes.string,
      id: PropTypes.number,
    })
  ),
};


參考文章:
https://www.npmjs.com/package/prop-types