Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

How do I use App.tsx instead of App.js in React?

$
0
0

I've created a react project with the instructions from it's documentation, which automatically has added the App.js file to the project. My issue is that I want to use App.tsx instead of App.js. For some reason, I am not able to run App.tsx file. How can I fix this, please?

I have read this question asked here, but I couldn't use it as it didn't make any sense to me since this is my first project with react.

This is my folder structure. enter image description here

It can be seen on this image, I get an error on the browser when I comment it out the App.js file. enter image description here

This is the index.js file, which is not changed.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

serviceWorker.unregister();

This is the package.json file

{
  "name": "dualnback",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.0",
    "@types/lodash": "^4.14.149",
    "@types/material-ui": "^0.21.7",
    "atob": "^2.1.2",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "bootstrap": "^4.4.1",
    "concurrently": "^5.0.0",
    "cookie-parser": "^1.4.4",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "express-session": "^1.17.0",
    "express-ws": "^4.0.0",
    "hammerjs": "^2.0.8",
    "jsonwebtoken": "^8.5.1",
    "lodash": "^4.17.15",
    "material-ui": "^0.20.2",
    "mongoose": "^5.7.8",
    "morgan": "^1.9.1",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "reactstrap": "^8.2.0",
    "rxjs": "~6.4.0",
    "rxjs-compat": "^6.5.3",
    "tslib": "^1.10.0",
    "typescript": "^3.7.3",
    "websocket": "^1.0.30",
    "zone.js": "~0.9.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@types/react-router-dom": "^5.1.3",
    "@types/reactstrap": "^8.2.0",
    "react-router-dom@next":"*"
  }
}

Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>