1

I am new to React apps so please excuse me if my question has an easy answer. I have spent the last few days with Google and have not found a solution for my question.

At my new position, I have been asked to modify a current React app. The short of it is that this app was built before my time and is old. The app does not permit for a dev build. And since it does not allow for a dev build our development team can not see the component layout, props, or state along with any other goodies provided by the React Dev Tools.

My question is how do I make my app work properly with the React Dev Tools?

Other details that may help: Files are located in ABC/app/src/common Normally here at my employer, this would translate into a URL of: www.ABC.com/app/. Yet for some reason, this is not how things are set up.

Instead the app is served from a URL subdomain: app.XYZ.com Also, note that the URL www.XYZ.com is not a React app - (not sure this is relevant)

Basically the build scripts create the bundle and the .min files are moved from the ABC/app/src/common folder to app.XYZ/.

package.JSON:

  "name": "ABC-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.0-14",
    "@fortawesome/free-solid-svg-icons": "^5.1.0-11",
    "@fortawesome/react-fontawesome": "0.1.0-11",
    "ajv": "^6.0.0",
    "alertifyjs": "^1.11.2",
    "axios": "^0.18.0",
    "babel-polyfill": "^6.26.0",
    "connected-react-router": "^4.4.1",
    "dateformat": "^3.0.3",
    "deep-freeze": "0.0.1",
    "fast-deep-equal": "^2.0.1",
    "fuse.js": "^3.4.6",
    "history": "^4.7.2",
    "i": "^0.3.6",
    "moment": "^2.22.2",
    "node-sass-chokidar": "^1.3.3",
    "npm": "^6.2.0",
    "prop-types": "^15.6.2",
    "react": "^16.5.0",
    "react-collapse": "^4.0.3",
    "react-dom": "^16.4.1",
    "react-html-parser": "^2.0.2",
    "react-loading": "^2.0.3",
    "react-motion": "^0.5.2",
    "react-redux": "^5.0.7",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^4.0.8",
    "react-scripts": "^1.1.4",
    "react-select": "^2.0.0",
    "react-table-container": "^2.0.1",
    "react-topbar-progress-indicator": "^2.0.0",
    "react-transition-group": "^2.4.0",
    "react-virtualized": "^9.20.1",
    "redux": "^3.7.2",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start": "yarn run build-css && react-scripts build && yarn run move-js && yarn run move-css",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "commit": "react-scripts build && yarn run move-js && yarn run move-css",
    "move-js": "cp ./build/static/js/main.*.js ../../app.XYZ.com/assets/js/main.js",
    "move-css": "cp ./build/static/css/main.*.css ../../app.XYZ.com/assets/css/main.css"
  },
  "proxy": "http://dev-app.XYZ.com/",
  "devDependencies": {
    "eslint": "^5.7.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "redux-devtools": "^3.4.1",
    "redux-logger": "^3.0.6",
    "why-did-you-update": "^0.1.1"
  },
  "browserslist": {
    "development": [
      "last 2 chrome versions",
      "last 2 firefox versions",
      "last 2 edge versions"
    ],
    "production": [
      ">0.25%",
      "not op_mini all",
      "ie 11"
    ]
  }
}
E_net4
  • 27,810
  • 13
  • 101
  • 139
davidhartman00
  • 353
  • 4
  • 14
  • 1
    `react 16.5.0` isn't that old, and FYI, version should match `react-dom`. So `npm start` doesn't build the app and start a local dev server for your project? Did the previous teams leave a README worth anything? – Drew Reese Feb 12 '20 at 01:39
  • Thanks, @DrewReese. We use `yarn run start`. IDK why but that is what we do here. I will update `react-dom` and now I'm wondering what is the downside of `react 16.5.0` using `react-dom 16.4.1`? In an ideal world, what files for the dev build would be created from running `npm start`? Do I have a README? LOLOL! Thanks for the optimism and the great laugh! The people that built this lost their jobs. This configuration is only the tip of the idiocy.. I mean iceberg. – davidhartman00 Feb 12 '20 at 17:24

2 Answers2

1

Try running react-scripts start in the root project folder.

The application should open a new browser window at http://localhost:3000 - then if you have the React DevTools Chrome extension installed you should be able to access the React DevTools tab

Jonathan Irwin
  • 5,009
  • 2
  • 29
  • 48
  • Thanks, @Jonathan Irwin. Running the command suggested produces: `react-scripts start -bash: react-scripts: command not found` – davidhartman00 Feb 12 '20 at 17:32
  • 1
    Have you installed the project dependencies by running `yarn` or `npm install` in the root first? That command should exist – Jonathan Irwin Feb 12 '20 at 17:34
  • Actaully I did both. The first time the `react-scripts start` did nothing. Then I tried running `yarn` and the `react-scripts start` but with no success. After getting the same result, I then tried `npm install` followed by `react-scripts start`. These make me wonder if I should uninstall and than reinstall? IDK? Either way thank you for the suggestions. Any help is great help in my book. – davidhartman00 Feb 12 '20 at 20:43
0

After some investigation and thanks to @JonathanIrwin and @DrewReese, I noticed that with in package.json file, inside the scripts sub-object there is scripts.start. This overwrites the default start command. Thus when the command npm start or yarn run start is executed node is running scripts.start which reads:

"start": "yarn run build-css && react-scripts build && yarn run move-js && yarn run move-css",    

To fix this, adding a new script reading:

"dev-start": "react-scripts start",

does the job. To execute this script anyone can run the command yarn run dev-start or npm dev-start from the terminal.

davidhartman00
  • 353
  • 4
  • 14