4/2/2018 - 5:45 PM

ReactJs - Component

Creating component

When creating components, you have the choice between two different ways:

  1. Functional components (also referred to as "presentational", "dumb" or "stateless" components).
  2. Class-based components (also referred to as "containers", "smart" or "stateful" components)
//Functional components 
import React from 'react';

const person = () => {
  return <p>I'm a Person!</p>

export default person;

//Class-based component
import React, { Component } from 'react';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <h1>Hi, I'm a React App</h1>