React - Stateless component

0 votes
147 views
added Mar 11, 2019 in React by LC Marshal Captain (25,790 points)

The component consist of 2 sub-components within. Header and Content were called in JSX tree. 

import React from 'react'

class StatelessComponent extends React.Component {
   render() {
      return (
         <div>
            <StatelessHeader/>
            <StatelessContent/>
         </div>
      );
   }
}
class StatelessHeader extends React.Component {
   render() {
      return (
         <div>
            <h1>Header here</h1>
         </div>
      );
   }
}
class StatelessContent extends React.Component {
   render() {
      return (
         <div> 
            <p>Content goes here</p>
         </div>
      );
   }
}
export default StatelessComponent;

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...