Error for static propTypes and defaultProps on Ubuntu 17.04
See original GitHub issueIs this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Environment
node -v
: v8.2.1npm -v
: 5.3.0npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.10
Then, specify:
- Operating system: OS: Ubuntu 17.04 zesty Kernel: x86_64 Linux 4.10.0-28-generic
Steps to Reproduce
- run create-react-app for creating project
- add static prop for App component like this:
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
static defaultProps = {
test: 'test'
};
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
export default App;
Expected Behavior
npm start
run without errors
Actual Behavior
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ReactJs, the SyntaxError with `static defaultProps`
The terminal executes npm install --save-dev babel-preset-stage-0 in the current directory. ... It could be some error in your webpack setup.
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Static PropTypes and Default Props (How To) - Treehouse
Static PropTypes and Default Props. In class components, it's common to define propTypes inside the class with the static keyword.
Read more >useeffect with async function Code Example - Code Grepper
const MyFunctionnalComponent: React.FC = props => { useEffect(() => { // Using an IIFE (async function anyNameFunction() { await loadContent(); } ...
Read more >리액트를 다루는 기술 [개정판]: 2.4.1 감싸인 요소 - 더북(TheBook)
다음 오류가 나타날 것입니다. Failed to compile. ./src/App.js Line 6: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had similar problems, installed eslint, babel-eslint and configured and it worked. I have Linux Mint by the way.
Updated https://github.com/borovik96/cra-static-error