question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error for static propTypes and defaultProps on Ubuntu 17.04

See original GitHub issue

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Environment

  1. node -v: v8.2.1
  2. npm -v: 5.3.0
  3. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.10

Then, specify:

  1. Operating system: OS: Ubuntu 17.04 zesty Kernel: x86_64 Linux 4.10.0-28-generic

Steps to Reproduce

  1. run create-react-app for creating project
  2. 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

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
talgat-rubycommented, Aug 5, 2017

I had similar problems, installed eslint, babel-eslint and configured and it worked. I have Linux Mint by the way.

0reactions
borovik96commented, Aug 15, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found