Yogesh Chauhan's Blog

What is a component helper function in React?

in React on June 7, 2021

Let’s create a simple React app with multiple components and change the code a bit:

Let’s add a function to get the birth year of the person in the People component.


The separate function is called when the People component is rendered. That function is nothing but a helper function.

How does the function get the age of the person?

The function inside the component has access to all the props that are passed to the component itself and that’s why we don’t need to specifically pass it into the function.

The separate helper function is inside the main function which is another feature of JavaScript.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
Filling a button background from left to right using CSSCSSHow to define constants in PHP?PHPLearn to Implement Estimated Reading Time using PHP Part 1: The BasicsPHPIN Operator in PostgreSQLPostgres3 JavaScript methods to use when you want to go back and forth in historyJavaScriptWordPress: How to display slider repeater fields in ACF?WordPressCanvas Drawing in HTML5HTMLHow to add navigation menu in Angular 9 app?AngularThe * arithmetic operator in Envision BasicEnvision BasicHow to float an image around texts?CSSHow to create a sidebar using pure CSS?CSSHow can one check to see if a remote file exists using PHP?PHP