Register Sample Module
Overview
The next step is to register SampleModule in module.js, the module's entry file. To demonstrate rendering, display "Sample Module" using a simple <div> element within the SampleModule component. This creates a basic screen setup for the module, which can be customized or expanded as needed.
Steps
Add the below code in the Module.js file which is already created.
import { Loader} from "@egovernments/digit-ui-react-components";
import React from "react";
export const SampleModule = ({ stateCode, userType, tenants }) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
const moduleCode = ["sample", "common","workflow"];
const language = Digit.StoreData.getCurrentLanguage();
const { isLoading, data: store } = Digit.Services.useStore({
stateCode,
moduleCode,
language,
});
if (isLoading) {
return <Loader />;
}
return ( <Switch>
<AppContainer className="ground-container">
<div>Sample Module </div>
</AppContainer>
</Switch>)
const componentsToRegister = {
SampleModule,
};
export const initSampleComponents = () => {
overrideHooks();
updateCustomConfigs();
Object.entries(componentsToRegister).forEach(([key, value]) => {
Digit.ComponentRegistryService.setComponent(key, value);
});
};
Initialize the module's custom hooks, configurations, and register components using
initSampleComponents()here.
Refer to the file here: Module.js
If there is a local server running, make sure to stop it. Restart by running
yarn installfollowed byyarn startat themicro-ui-internalslevel.
Hurray! Now, the screen is displayed below on visiting the given URL:

Refer to the below sections for a deeper understanding
Reusable Components
Reusable Hooks
Employee Module Setup
Last updated
Was this helpful?