Q:

Calling function with JSX code in handler

I would like to render a Loader when my page gives me an error and redirects to the Login Page. 
My Loader code is as below. 
 export const Loader = () => (
    <Grid container justify="center" align="center" style={{ height: '100%' }} >
        <Grid item >
            <CircularProgress />
        </Grid>
      </Grid>
 );

Below is where I would to call.  It's in another file.  
handleRequestClose = () => {
    const { errorActions } = this.props;
    errorActions.close();
    if (this.props.isLogined && isLogined()) {
      // Render Loader before the time runs out and redirects me
      window.setTimeout(function() {
        window.location.href = '/';
      }, 9000);
    }
  };`

In what way can I call Loader there?  Do I need to import Loader and then just invoke it like a function?  

A:

You should call setState, for example this.setState({ isLoading: true }) and in the render method call your Loader (but you must import it to your file), as

render() {
  if (this.state.isLoading) { return <Loader />}
}

