Skip to content

S1 L10 - Difference Between Component Instances and Component Classes  #1

@ngminhtrung

Description

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

const App = function() {
   return <div>Hi!</div>;
}

ReactDOM.render(App);

Báo lỗi: Tham số truyền vào cho ReactDOM.render() là một class thay vì 1 instance. Như vậy ở đây App là một class.

Sửa lỗi: Muốn gọi 1 instance của class App, ta phải thay bằng <App />, tức là

ReactDOM.render(<App />);

PS: Lưu ý đoạn code trên vẫn có lỗi khi chưa chỉ rõ target của method render().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions