useTheme hook let's us access the currently active theme. You can use it in your own components to have them respond to changes in the theme.
See theming guide for more details and usage guide around how to configure themes.
Using with class component
You can wrap your class component in a function component to use the hook: