Difference between React Component and React Element

前端 未结 11 1902
栀梦
栀梦 2020-12-02 07:29

What is the difference between React Component and React Element? The documentation mentions both but does not go into detail, some methods require components, other element

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 07:42

    React Element - It is a simple object that describes a DOM node and its attributes or properties you can say. It is an immutable description object and you can not apply any methods on it.

    Eg -

    
    

    React Component - It is a function or class that accepts an input and returns a React element. It has to keep references to its DOM nodes and to the instances of the child components.

    const SignIn = () => (
      

    Sign In

    );

提交回复
热议问题