Questions tagged [create-react-app]

create-react-app is a starter-kit for creating React applications with no build configuration. If you’re getting started with React, use this to automate the build of your application. There isn't any configuration file, and react-scripts is the only extra build dependency in your package.json file. Your environment will have everything you need to build a modern React application.

Getting Started

5893 questions
3
votes
2 answers

How to write a React Stateless Functional Component in Typescript?

I have this: import React, { useReducer } from 'react'; import { Item, List } from '../Types'; type Props = { items: List; }; const TodoList: React.SFC = ({ items, children }) => { return items.map((item: Item) =>
johnnyshrewd
  • 1,038
  • 2
  • 12
  • 29
3
votes
1 answer

React not fetching data from the updated env file

There are some environment variables in my .env file that gets updated when some values get updated on the database. Example: REACT_APP_FIREBASE_ID=1234567890 When I log this to the console on my react…
Saurabh
  • 2,655
  • 1
  • 20
  • 47
3
votes
0 answers

How to solve critical css with Create React App?

How are you handling critical css with in CRA project? I tried to use const Critters = require('critters-webpack-plugin'); Critters github official page Critters webpack plugin with react-app-rewired. Also I tried to use isomorphic-style-loader…
Patryk Janik
  • 2,476
  • 2
  • 13
  • 23
3
votes
3 answers

Where to place webpack.config.js in create-react-app project

I have been instructed to put some instructions inside the webpack.config.js file. However in my create-react-app project I cannot find that file. Currently the available answer on StackOverFlow requires ejecting the project which I think will break…
preston
  • 3,721
  • 6
  • 46
  • 78
3
votes
0 answers

How to make absolute path in create react app?

I have configured my eslint config to use absolute path . I used this manual https://dev.to/oliverandrich/absolute-imports-with-create-react-app-and-vscode-ihn . Everything runs fine, but eslint shows an error "Absolute imports should come before…
Yerlan Yeszhanov
  • 2,149
  • 12
  • 37
  • 67
3
votes
1 answer

jest test cannot import cesium using create react app and craco

I am using create react app with craco, and craco-cesium to load cesium into my project. I am trying to setup jest to start creating tests but the issue is Cesium is using requireJS. I added the following to my package.json // package.json ... …
ArmenB
  • 2,125
  • 3
  • 23
  • 47
3
votes
0 answers

Trying to deploy React app on heroku. App's api works fine locally but when I deploy to heroku the api doesn't work

I am using Node+Express for my back-end. At first I tried using "proxy": http://localhost:3001 in the react client's package.json but that caused an Invalid Host Header message when I tried to open my site on heroku. I followed these insturctions…
3
votes
1 answer

Heroku create-react-app deploy Uncaught SyntaxError: Unexpected token <

Whenever I deploy my heroku app with the create-react-app buildpack, the first time I try to access my domain, the page loaded is white and there is an error in the developer console saying Uncaught SyntaxError: Unexpected token < in the file…
rma
  • 1,853
  • 1
  • 22
  • 42
3
votes
1 answer

How to specify the custom URL when i enter npm start in create-react-app

I wanted to load custom URL when i load the react using npm start in create-react-app. By default it will open localhost:somePort/. But i need locahost:somePort/somestuff
iamPavan
  • 255
  • 4
  • 15
3
votes
1 answer

create-react-app with Firebase hosting init script

I'm trying to follow step 3 here, "Add Firebase SDKs and initialize Firebase", with the "From Hosting URLs" I'm including these three scripts inside the head section of the public/index.html page:
Pat Needham
  • 5,698
  • 7
  • 43
  • 63
3
votes
3 answers

create-react-app returns an Error: Cannot find module 'react-scripts/scripts/init.js' when executed

when I try to create a react project with both npm and yarn, it shows me the following error: I tried to reinstall node and make sure it was up to date, as well as create-react-app by running npm install -g create-react-app@latest. I also removed…
Enzo
  • 31
  • 1
  • 6
3
votes
0 answers

Serverless Offline <> React - Local Dev Page Load

I have a serverless application that is using the serverless-offline plugin and create-react-app to load a front-end client, but I'm not sure how I can configure my serverless app to load the index.html page and also the proper link format that I…
cphill
  • 5,596
  • 16
  • 89
  • 182
3
votes
1 answer

Mock fetch in Jest tests throwing “invalid json response” and “Unhandled promise rejection” errors

I’m trying to do unit tests for some of my redux-saga generators and am getting a couple of errors I’m not sure how to resolve. I’m using create-react-app, so my testing suite is Jest and Enzyme. A basic example: Setup: src/setupTests.js import…
Brandon Durham
  • 7,096
  • 13
  • 64
  • 101
3
votes
1 answer

NPM test getting mysteriously stuck when run in Jenkins

We have two TypeScript apps, both created through CRA, and a CI pipeline which runs a series of npm commands to run tests/lint and build the apps for later stages: time npm install --no-optional --unsafe-perm npm test -- --coverage npm run tsc npm…
Alyssa
  • 835
  • 1
  • 7
  • 23
3
votes
2 answers

Create React App: how to get final port dev-server running on

From https://facebook.github.io/create-react-app/docs/advanced-configuration you can provide your own script to BROWSER environment variable. On this script, I want to open link to some other page, with a query parameter to redirect to port the…
Kousha
  • 32,871
  • 51
  • 172
  • 296