Class Based React Component

A class based React component is used to manipulate data and create new states and variables.

Before we learn more about states and variable data management let’s know the basic structure of a class based component in react.

Don’t forget all the components in react start with a capital letter else react treat components as tags html tags. for example a componet with class name ‘button’ can not be used insted first letter capital ‘Button’ is can be used not only tag words but all component names should start with capital Letter

Sample code for class based component:

import React, { Component } from 'react'
export default class Class_name extends Component {   
 render() {        
             return ( ) 
           }
}

This is a class so variable can and functions can be declared in similar to any programming language.

Leave a comment

Design a site like this with WordPress.com
Get started