Setup your development environment
To easily set up a React application, use create-vite-app, which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-app, refer to this documentation for more details.
To create a new React application, run the following command.
npm create vite@latest my-appTo set-up a React application in TypeScript environment, run the following command.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm run devTo set-up a React application in JavaScript environment, run the following command.
npm create vite@latest my-app -- --template react
cd my-app
npm run devGetting Started
8 May 20256 minutes to read
Initialize the Spinner using createSpinner method.
You can show/hide Spinner by using showSpinner and hideSpinner methods accordingly. You need to set target to render based on specific target.
The following steps explains you on how to create and how to show/hide your Spinner.
*Import the createSpinner method from ej2-popups library into your file as shown in below.
import { createSpinner } from '@syncfusion/ej2-popups';
*Show and hide this spinner by using showSpinner and hideSpinner methods for loading in your page and import them in your file as shown in below.
import { showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
Create the Spinner globally
The Spinner can be render globally in a page using public exported functions of the ej2-popups package.
[Class-component]
import { createSpinner, showSpinner } from '@syncfusion/ej2-popups';
import * as React from 'react';
export default class App extends React.Component {
componentDidMount(prevProps) {
//createSpinner() method is used to create spinner
createSpinner({
// Specify the target for the spinner to show
target: document.getElementById('container'),
});
// showSpinner() will make the spinner visible
showSpinner(document.getElementById('container'));
}
render() {
return (<div className="control-pane">
<div id="container" className="control-section col-lg-12 spinner-target"></div>
</div>);
}
}import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
import * as React from 'react';
import * as ReactDOM from "react-dom";
export default class App extends React.Component<{}, {}> {
componentDidMount(prevProps) {
//createSpinner() method is used to create spinner
createSpinner({
// Specify the target for the spinner to show
target: document.getElementById('container'),
});
// showSpinner() will make the spinner visible
showSpinner(document.getElementById('container'));
}
render() {
return (
<div className="control-pane">
<div id="container"
className="control-section col-lg-12 spinner-target"
></div>
</div>
);
}
}[Functional-component]
import { createSpinner, showSpinner } from '@syncfusion/ej2-popups';
import * as React from 'react';
import { useEffect } from "react";
function App() {
useEffect(() => {
componentDidMount();
});
function componentDidMount(prevProps) {
//createSpinner() method is used to create spinner
createSpinner({
// Specify the target for the spinner to show
target: document.getElementById('container'),
});
// showSpinner() will make the spinner visible
showSpinner(document.getElementById('container'));
}
return (<div className="control-pane">
<div id="container" className="control-section col-lg-12 spinner-target"></div>
</div>);
}import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
import * as React from 'react';
import * as ReactDOM from "react-dom";
import { useEffect } from "react";
function App() {
useEffect(() => {
//createSpinner() method is used to create spinner
createSpinner({
// Specify the target for the spinner to show
target: document.getElementById('container'),
});
// showSpinner() will make the spinner visible
showSpinner(document.getElementById('container'));
})
return (
<div className="control-pane">
<div id="container"
className="control-section col-lg-12 spinner-target"
></div>
</div>
);
}
export default App;