SlideShare a Scribd company logo
1 of 10
By Heber
Silva
Pronounce: (Irish:
Éibhear or Hebrew:
HÉber)
It receives a function as input and/or return a
new function as output
Higher Order Function
Also called First Class Citizen or First Order
Functions
Examples of Higher Order Functions
High Order Arrays
High Order Components (HOCs) are functions that
accept components as parameters and return an
enhanced component
What are Higher Order
Components?
Use of HOCs
Component to
wrap
The Higher-Order Component
Implementin
g the HOC
Use of HOC
More live code!
Dryer code
Create more modular code
Emphasizes functional programming to stress data immutability
Avoid code duplication
Easy to maintain and to work with
CODE REUSABILITY!
What you get from HOCs

More Related Content

What's hot

Embedded SW Interview Questions
Embedded SW Interview Questions Embedded SW Interview Questions
Embedded SW Interview Questions
PiTechnologies
 

What's hot (20)

Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Clean code
Clean codeClean code
Clean code
 
Fetch API Talk
Fetch API TalkFetch API Talk
Fetch API Talk
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Types of function call
Types of function callTypes of function call
Types of function call
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
Function lecture
Function lectureFunction lecture
Function lecture
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
Higher Order Components and Render Props
Higher Order Components and Render PropsHigher Order Components and Render Props
Higher Order Components and Render Props
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React Hooks
React HooksReact Hooks
React Hooks
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
Embedded SW Interview Questions
Embedded SW Interview Questions Embedded SW Interview Questions
Embedded SW Interview Questions
 
Typedef
TypedefTypedef
Typedef
 
Recursion
RecursionRecursion
Recursion
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Higher Order Component React

Editor's Notes

  1. Hi everyone, my name is Lee Byron and I work at Facebook on a team responsible for building the tools and technology to make it easier to build high quality products. Over the last few years I've worked on a bunch of stuff you may have heard of including GraphQL, Immutable.js, and what I'm here today to talk about: React.
  2. React was started at Facebook in 2012
  3. Functions are said to be first class citizens or first order functions when that functions are treated as variable. A function is passed as argument.
  4. High order components are functions that accept a components as parameters and return an enhanced component. Before we can go deeper on HOC, let’s step back and understand the High Order pattern.
  5. Manipulate props. Inheritance inversion – The HOC can have access to the state, life cycle hook of the wrapped component. Render Highjacking – Render something entirely different then the original component. *Live code: 1) style wrapping – Title component 2) Highjacking – Home component - loggedIn
  6. Here’s a stateless dashboardheader component. If there is a user on the props, it will return the welcome message and the user name
  7. Here’s our new Higher Order Component that takes a Component as argument and return an enhanced component with a new prop called userInfo so the component that is being wrapped can have access to that prop user. To use the Higher Order Component, just pass the Component to withUser function as input and then assign an enhanced component with User info.
  8. Higher-Order Components are just High Order Functions and they should be pure functions. No side effects. We don’t want to mutate any data. Data are always passed arguments. Also, they have to be predictable. Live code: 1) CatWihoutHOC 2) Let’s refactor this Cat. CatWithHOC – withForm HOC
  9. Manipulate props. Inheritance inversion – The HOC can have access to the state, life cycle hook of the wrapped component