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 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #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

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
How JavaScript classes allows us to do less typing (syntactic sugar)?JavaScriptHow to Remove PHP File Extensions From Your Website URLs?PHPHow to pass arguments in SCSS function?SCSSHow to create HTML elements with ID and class using JavaScript?HTMLUnderstanding the confusing and handy “This” keyword in JavaScriptJavaScriptadd_filter function in WordPressWordPressHow to create a full screen loader using CSS and JavaScript?CSSJavaScript Input Validation Theme Park Example using throw StatementJavaScriptHow to change CSS with JavaScript?CSSHow to create a simple slider with CSS and jQuery?CSSHow to create a circle that follows a cursor using JavaScript and CSS?CSSAll different methods for accessing elements in the DOM using JavaScriptJavaScript