ReduxSimpleStarter icon indicating copy to clipboard operation
ReduxSimpleStarter copied to clipboard

Class method issue

Open Balajisivakumar92 opened this issue 6 years ago • 2 comments

I am getting error message when I am using class method . error message : TypeError: Super expression must either be null or a function, not undefined

here is my code : search_bar.js


import React from 'react';
class SearchBar extends React.component {
    render() {
        return <input />;
    }
}

export default SearchBar;

here is my code : index.js


import React from 'react';
import ReactDOM from 'react-dom';

import SearchBar from './components/search_bar';

const API_KEY = 'AIzaSyAXOBp2n4bKsYZYorX0HIerLGK6sqwvuwc'; 

// create a new component. This component should produce
// some HTML 

const App = () => {
    return (
    <div>
        <SearchBar />
    </div>
    );
}

// Take this component's generated HTML and put it
// on the page (in the DOM)

ReactDOM.render(<App />, document.querySelector('.container'));

help me to solve this error.

Balajisivakumar92 avatar Aug 26 '18 06:08 Balajisivakumar92

In your search_bar.js class SearchBar extends React.component {

change the component to Component

beware of the big letters.

kelvinkhai avatar Aug 27 '18 03:08 kelvinkhai

In your search_bar.js you should do this class SearchBar extends React.Component { render() { return ; } }

vinay72 avatar Sep 15 '18 00:09 vinay72