Functional Components vs Class Components

Functional components in React Native are JavaScript functions that render a React element. They can accept a single argument which is an object containing component properties.

Class Components in React Native are ES6 Classes that extend from a base class.

Functional components Class Components
Like normal JavaScript functions, Functional components can be defined using the arrow function or the function keyword. A class component is an class that extends from React base class. It requires a render() method.
Class components initialize a state in its constructor. Functional components make use of the useState hook
A functional component is just a plain JavaScript pure function. Class Component create a render function which returns a element
Hooks can be easily used in functional components to make them Stateful. It requires different syntax inside a class component.
Constructors are not used. Constructor are used as it needs to store state.
Syntax :
 function Welcome() {
 return  Hello, Aman;
}
Syntax :
 class Welcome extends React.Component { render() {
 return Hello, Aman;
 } }

Comments

Post a Comment

Popular posts from this blog

Exploring the New Architecture of React Native for SEO-Friendly Mobile Apps

Streamlining Mobile App Deployment with App Center CodePush: A Comprehensive Guide

React Native - Overview