Skip to content

withTheme

Function
withTheme<C>(ComponentC, multiThemeboolean): ThemedComponent<C>

A higher-order component that provides the current theme as a prop to the wrapped child and listens for changes. If the theme is updated, the child component will be re-rendered accordingly.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
import { withTheme } from 'jimu-theme'

const MyComponent = ({ theme }) => (
  <div style={{ backgroundColor: theme.sys.color.surface.paper }}>
    Hello World
  </div>
)

export default withTheme(MyComponent)
Type Parameters
ParameterType
CComponentType<ComponentProps<C>>
Parameters
ParameterTypeDefault
ComponentC
multiThemebooleanfalse
Returns 
ThemedComponent<C>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.