Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Super expression must either be null or a function, not undefined - reactjs

I'm a beginner at react.js.

I got this error:

Super expression must either be null or a function, not undefined

full error output in my browser chrome console:

Uncaught TypeError: Super expression must either be null or a function, not undefined at _inherits (bundle.js:21166) at bundle.js:21172 at Object.184.react (bundle.js:21196) at s (bundle.js:1) at e (bundle.js:1) at bundle.js:1

my codes:

const React=require('react');
const ReactDom=require('react-dom');

class App extends React .component{

    render(){
        return(
            <div>
                < Header />,
                < Main />,
                < Footer />
            </div>
        );
    }
}

class Header extends React .component{
    render(){
        return(
            <Header>
                <nav>
                    <h1>Header</h1>
                </nav>
            </Header>
        );
    }
}


class Main extends React .component{
    render(){
        return(
            <div>
                <p> text 1</p>
            </div>
        );
    }
}

class Footer extends React .component{
    render(){
        return(
            <h2>Footer</h2>
        );
    }
}

ReactDom .renderToStaticMarkup (<App /> ,document.getElementById('app'));
like image 330
zahra khalafi Avatar asked Sep 11 '17 08:09

zahra khalafi


2 Answers

You should change React.component to React.Component capital C.
e.g-class main extends React.Component. In addition to that, remove the space between React. and Component

like image 87
Debabrata Avatar answered Nov 06 '22 01:11

Debabrata


It seems that you're extending the classes wrong. It should be React.Component, not React.component

like image 23
Daniel Andrei Avatar answered Nov 05 '22 23:11

Daniel Andrei