menu

Questions & Answers

Abp Lepton theme: left side menu broken: features[featureKey].toLowerCase() undefined

ABP Framework version: 6.0.1
Lepton version: 6.0.1

The project was created using Abp Suite and ran, and this happened:

ERROR TypeError: Cannot read properties of undefined (reading 'toLowerCase')
in file: volo-abp.ng.theme.lepton.mjs:1266:42

Going to that line in the file this is what I found:

const LEPTON_THEME_FEATURES = new InjectionToken('LEPTON_THEME_FEATURES', {
    providedIn: 'root',
    factory: () => {
        const configState = inject(ConfigStateService);
        const featureKey = 'LeptonManagement.Enable';
        const mapFn = features => ({
            
        // The prolem is here: Uncaught ReferenceError: features is not defined
            enable: features[featureKey].toLowerCase() !== 'false',
        });
        return featuresFactory(configState, [featureKey], mapFn);
    },
});

Kindly how do I solve this problem?

enter image description here

Comments:
2023-01-17 23:42:03
Can you please read about the problems with images of text and then edit to add transcriptions of your images of text into actual text? Perhaps useful: /help/formatting.
Answers(1) :

I could see only place it broken in your code is this features[featureKey].toLowerCase()

Try add safe check.

const mapFn = features => {
    let enable = false;
    if (features[featureKey]) {
        enable = features[featureKey].toLowerCase() !== 'false',
    }
   return {
    enable
   }
};