reactjs

What is producing “Invalid option for project: true” when running 'tslint --project' on a React project?

夙愿已清 提交于 2021-02-09 09:20:23
问题 I'm trying to set up tslint to work on a small sample React/Typescript project, following a tutorial online. When I either run yarn lint or simply enter tslint --project in the terminal, I keep getting the error Invalid option for project: true I've done a lot of googling, and I can't find what I'm doing wrong. My tslint.json is { "extends": [ "tslint:recommended", "tslint-react", "tslint-config-prettier" ], "rules": { "ordered-imports": false, "object-literal-sort-keys": false, "no-console":

What is producing “Invalid option for project: true” when running 'tslint --project' on a React project?

烈酒焚心 提交于 2021-02-09 09:19:29
问题 I'm trying to set up tslint to work on a small sample React/Typescript project, following a tutorial online. When I either run yarn lint or simply enter tslint --project in the terminal, I keep getting the error Invalid option for project: true I've done a lot of googling, and I can't find what I'm doing wrong. My tslint.json is { "extends": [ "tslint:recommended", "tslint-react", "tslint-config-prettier" ], "rules": { "ordered-imports": false, "object-literal-sort-keys": false, "no-console":

How do I fix typescript compiler errors on css files?

女生的网名这么多〃 提交于 2021-02-09 09:05:45
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

How do I fix typescript compiler errors on css files?

被刻印的时光 ゝ 提交于 2021-02-09 09:04:27
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

How do I fix typescript compiler errors on css files?

。_饼干妹妹 提交于 2021-02-09 09:03:13
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

Heroku H10 works on localhost, won't work in deployment

笑着哭i 提交于 2021-02-09 09:01:58
问题 This error seems to be pretty popular here! The app works great locally, but when deploying to Heroku... crickets, Application crashes. This is server.js var app = express(); var PORT = process.env.PORT || process.env.REACT_APP_PORT; app.use(express.urlencoded({ extended: true })); app.use(express.json()); (process.env.NODE_ENV === "production") ? app.use(express.static("build")) : app.use(express.static("public")); //code goes here app.use(cors()); app.get('*', function (req, res) { res

Access to XMLHttpRequest has been bloked by CORS policy

一个人想着一个人 提交于 2021-02-09 08:58:23
问题 Access to XMLHttpRequest at 'http://localhost:8080/ws' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 回答1: When invoking an XMLHttpRequest , the browser makes a preflight request and checks for an Access-Control-Allow-Origin header to determine whether the request should be allowed. You should edit your server code to send that

Heroku H10 works on localhost, won't work in deployment

混江龙づ霸主 提交于 2021-02-09 08:58:09
问题 This error seems to be pretty popular here! The app works great locally, but when deploying to Heroku... crickets, Application crashes. This is server.js var app = express(); var PORT = process.env.PORT || process.env.REACT_APP_PORT; app.use(express.urlencoded({ extended: true })); app.use(express.json()); (process.env.NODE_ENV === "production") ? app.use(express.static("build")) : app.use(express.static("public")); //code goes here app.use(cors()); app.get('*', function (req, res) { res

react route using browserhistory changes url but nothing happens

[亡魂溺海] 提交于 2021-02-09 08:44:49
问题 I'm trying to get a react router to work. This is my code: var hashHistory = require('react-router-dom').hashHistory; var BrowserRouter = require('react-router-dom').BrowserRouter; var Route = require('react-router-dom').Route; var ReactDOM = require('react-dom'); var React = require('react'); var Index = require('./index'); var Login = require('./login'); ReactDOM.render( <BrowserRouter history={hashHistory}> <div> <Route path="/" component={Index} /> <Route path="/login" component={Login} /

Using 'ref' as array in React

落爺英雄遲暮 提交于 2021-02-09 08:01:28
问题 I have some issues when im trying to reference inputs as arrays in React with Redux. The code below maps one Panel per article in the array. var articles = this.props.item.array.articles.map((article, index) => { return <Panel key={index} header={'Article ' + index}> <Input type='select' ref='id' label='Article' defaultValue={article.id} > {articles} </Input> </Panel> }) I'm trying to construct the refs so that they're in an array format, which does not seem to be possible at the moment.