create-react-app

create-react-app keeps post-ES5 JavaScript

杀马特。学长 韩版系。学妹 提交于 2021-02-05 05:25:07
问题 I am using the TypeScript flavor of create-react-app: npx create-react-app my-app --typescript When I build the app, the bundle still includes post-ES5 code such as Symbol. What am I missing? My tsconfig file: { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution":

How can I make jest run with the same config as react-script test on a create-react-app?

我与影子孤独终老i 提交于 2021-02-04 19:23:12
问题 I know I can run npm test which runs react-script test and it works, it successfully run the tests. But I'm interested in figuring out how to run jest directly with the same configuration react-script uses. Hopefully without having to replicate the configuration or ejecting the app. I started reading the source code of react-scripts but so far I couldn't figure it out. The reasons for wanting this are: My CRA project is part of a bigger project, and I could just run jest on the top level and

Concurrently JS application pipeline install and build hangs (Express js for server, Create-React-App for Client)

柔情痞子 提交于 2021-02-02 09:46:47
问题 Problem : I have a project with a server (Express Server that handles file uploading and deleting) and client (Front End Create-React-App). The project structure looks like follows: Root Folder With Server Client Folder Each folder has it's own package.json. Server Package.json. Client package.json I'm trying to build and deploy onto azure however the pipeline hangs on "npm install and build". It seems like the build succeeds but this phase just hangs. Here is my server.js (the routes are not

Why does create-react-app create the App.js file as a functional component?

核能气质少年 提交于 2021-01-29 14:23:55
问题 I'm trying to learn React and I noticed that when I used npx create-react-app my-project , it created the App.js file as a functional component, as opposed to a class component, as it did in past versions. I found this commit on create-react-app's repo where they changed it. What I'm trying to figure out, is why they did this? I read this article on class components vs. functional components and as far as I understand it, functional components are stateless. I must be misunderstanding, or

Why does this give a Typescript warning?

限于喜欢 提交于 2021-01-29 13:51:10
问题 Why does the second call to needsString(var1) in this .tsx component give a warning, but not the first or third calls? And if I change the code to use var2 instead of var1 (which I think have exactly the same types), I don't get a warning. What gives? import { useParams } from "react-router-dom"; const DeleteTeams2 = ({ var2 } : { var2: string | undefined})=> { // use var here so that var1 and var2 get exactly the same types var { var1 } = useParams(); function needsString(str : string) :

When mutating a module object, why are curly brace imports not changed?

青春壹個敷衍的年華 提交于 2021-01-29 12:20:39
问题 I'm playing around with tidying up a code base that does some direct module mutations, rather than using any mocking behaviour, and I've noticed something odd. If I, starting with a fresh create-react-app do something like this in a test: import React from 'react'; import { render } from '@testing-library/react'; import App from './App'; import lodash from "lodash"; test('renders learn react link', () => { // Directly mutating the module React.useContext = jest.fn(); React.foo = "foo"; lodash

Getting error when npm start with React application

 ̄綄美尐妖づ 提交于 2021-01-29 11:50:01
问题 I'm having this problem whenever I create a new React folder using npx create-react-app test . npm start does not work and throws this error message in the terminal > test@0.1.0 start C:\Users\franc\Desktop\test > react-scripts start i 「wds」: Project is running at http://192.168.56.1/ i 「wds」: webpack output is served from i 「wds」: Content not from webpack is served from C:\Users\franc\Desktop\test\public i 「wds」: 404s will fallback to / Starting the development server... events.js:288 throw

NGINX server not applying the CSS files

血红的双手。 提交于 2021-01-29 09:34:02
问题 I have a create-react-app based React App. I am currently serving it using NGINX. I generated the build directory and serving it as a root in NGINX. My NGINX conf currently looks like this: http { server { listen 80; root /home/react-app/build; index index.html; location / { try_files $uri /index.html; } } } However when I load the page, the JS and html files are loading. However the CSS is not being applied. Also, when I checked the network tab in browser developer tools, I see that the CSS

Create-react-app returns “Cannot find module 'rxjs'”

风流意气都作罢 提交于 2021-01-29 09:28:51
问题 I've just installed NodeJS and NPM in a new machine. I added rxjs package in all my existing projects in order to make then start properly. However, when I run create-react-app - using npm globally or npx - I receive "Error: Cannot find module 'rxjs' ". Seems like rxjs is a new dependency of something (considering it's affecting old projects too). I have already changed Node version to 8, 10 and 12. Reinstalled NPM, changed CRA version to 2.x.x and the trouble persists. How can I use CRA

Unexpected character ' ' (1:0) in node_modules\create-react-context\lib\index.js

北战南征 提交于 2021-01-29 09:23:22
问题 This keeps happening in create-react-app every time I add a package using yarn. ./node_modules/create-react-context/lib/index.js SyntaxError: d:\project\client\node_modules\create-react-context\lib\index.js: Unexpected character ' ' (1:0) > 1 | | ^ I have to copy this https://github.com/jamiebuilds/create-react-context/blob/master/src/index.js and paste it to node_modules\create-react-context\lib\index.js every time to get rid off that error. I'm using VSCodium as my editor. How can I get rid