0

I have a problem with react component,then,Uncaught TypeError: Class extends value undefined is not a constructor or null.I try to delet the 'extends React.Component',but It`s fale..thanks for your help.

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

class Boss extends React.Component() {
    handlClick() {
        return alert('我是主页');
    }

    render() {
        return (
            <div class="goto">
            </div>
        );
    }
    
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Boss />);```





1 Answer 1

0

it is React.Component not React.Component()

class Boss extends React.Component{
//...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.