What are Components in ReactJS ?

devquora
devquora

Posted On: Feb 22, 2018

 

React Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

Below is ample component written in ES6 class to display a welcome message on the screen.

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name} </h1>;
  }
}

const element = <Welcome name="Sara" />;
ReactDOM.render(
  element,
  document.getElementById('root')
);

source: https://facebook.github.io/react/docs/components-and-props.html

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    React Js Interview Questions

    What is ReactJS ?

    React js is javascript based UI Library developed at Facebook, to create an interactive, stateful &amp; reusable UI com..

    React Js Interview Questions

    List some advantages of ReactJS ?

    Advantages of React JsReact.js is extremely efficient: React.js creates its own virtual DOM where your components act..

    React Js Interview Questions

    What is JSX in React Js?

    JSX is an XML/HTML-like syntax used by React that extends ECMAScript so that XML/HTML-like text can co-exist with JavaS..