Hello Laurence
I have implemented the code as per above instruction. But, when I am clicking on button to change the dark mode getting some error. Like : TypeError: Cannot read property 'primary' of undefined
Can you please help me that what are the reason behind of this?
Hi Sahil,
So I was just looking at the above code, and I can see where it might be going wrong. So if you look for the line where I say Now we can create our dark theme, and export it., I don't say explicitly where to export that file to. So what you need to do is go to themes/index.ts, and add the dark theme in.
// src/themes/index.ts
import base from './base';
import dark from './dark'; // add this
import { IThemes } from './utils';
/**
* The default theme to load
*/
export const DEFAULT_THEME: string = 'base';
export const themes: IThemes = {
base,
dark, // add this
};
Now, when the applyTheme function looks at your exported themes, it will be able to find your dark theme and apply it. Hope that helps!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello Laurence
I have implemented the code as per above instruction. But, when I am clicking on button to change the dark mode getting some error. Like : TypeError: Cannot read property 'primary' of undefined
Can you please help me that what are the reason behind of this?
Hi Sahil,
So I was just looking at the above code, and I can see where it might be going wrong. So if you look for the line where I say
Now we can create our dark theme, and export it.
, I don't say explicitly where to export that file to. So what you need to do is go tothemes/index.ts
, and add the dark theme in.Now, when the
applyTheme
function looks at your exported themes, it will be able to find your dark theme and apply it. Hope that helps!