What is the difference between Element and Component in react js


Element:

An element is a plain object describing what you want to appear on the screen in terms of the DOM nodes.

Creating a react element is cheap and once it is created it cannot be mutated.

const element = React.createElement(
  'div',
  {id: 'login-btn'},
  'Login'
)
The above code returns a JSON object containing type and props and it is then rendered by ReactDOM.render();

Component:

There are multiple ways of declaring a component, like a function or a class. The component takes input as props and then returns JSX.

const Button = ({ onLogin }) =>
  <div id={'login-btn'} onClick={onLogin}>Login</div>