Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
React Js

I want to use a load panel all over the pages from a function call like ShowLoadingPanel() and HideLoadingPanel(). How can I achieve that with making a common component so that I don't have to declare it on all of the pages?

What I have tried:

Page1
JavaScript
<pre>import React from "react";
import { LoadPanel } from "devextreme-react/load-panel";

export default class extends React.Component {
  state = {
    loadPanelVisible: true,
  };

  componentDidMount() {
    this.setState({
      loadPanelVisible: false,
    });
  }

  render() {
    return (
      <React.Fragment>
        <LoadPanel visible={this.state.loadPanelVisible} />
      </React.Fragment>
    );
  }
}


Page2
JavaScript
<pre>import React from "react";
import { LoadPanel } from "devextreme-react/load-panel";

export default class extends React.Component {
  state = {
    loadPanelVisible: true,
  };

  componentDidMount() {
    this.setState({
      loadPanelVisible: false,
    });
  }

  render() {
    return (
      <React.Fragment>
        <LoadPanel visible={this.state.loadPanelVisible} />
      </React.Fragment>
    );
  }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900