Creating Helper Functions in ReactJS

If you are making helper functions, you should instead make a file that exports functions like this:

export function MyHelperFunc_1() {


export function MyHelperFunc_2() {


Then import them like so:

import { MyHelperFunc_1 } from ‘./helpers’

If you want to create a helper function that accepts a callback, you can do it like this:

export function MyHelperFunc_1(data, callback) {
 let response = do_ajax(data);
 if( response.status == 1 ){
  callback(response); // pass the response

Then use it like this:

MyHelperFunc_1(my_data, function(response){
 alert(response.message); // display the response


Do you need help with a project? or have a new project in mind that you need help with?

Contact Me