I am new in js reaction, my problem is that I want to create a class that will work as a global helper that I want to use in another class or component.
Use an example for an example. First I want to get all the resturant list keyword entered by the user if the user selects any restaurant, then I want to get information about the restaurants. in this case I have to make two ajax calls. I want to create a global ajax helper function that I can use in other components.
class AjaxHelperClass{ ResturantAPI(url){ $.ajax({ url : url, success : function(res){} }); } } export default AjaxHelperClass;
in my other component, which is used from my AjaxHelperClass function:
import React from 'react'; import {render} from 'react-dom'; import {AjaxHelperClass} from "./module/AjaxHelperClass" class App extends React.Component { constructor(props) { super(props);
source share