should i use typescript with react code example
Example 1: React with Typescript
npx create-react-app yourProjectName --template typescript
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
Example 2: react-native use typescript
yarn add --dev typescript @types/jest @types/react @types/react-native @types/react-test-renderer
# or for npm
npm install --save-dev typescript @types/jest @types/react @types/react-native @types/react-test-renderer
Example 3: react-native use typescript
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
Example 4: why use typescript with react
npm install --save typescript @types/node @types/react @types/react-dom @types/jest