Skip to content

Commit 92c5dd1

Browse files
committed
remove tick and add types for ThemeProvider
1 parent cf04e13 commit 92c5dd1

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import MenuItem from './components/Menus/MenuItem'
4444
import MenuDivider from './components/Menus/MenuDivider'
4545
import DropdownMenu from './components/Menus/DropdownMenu'
4646
import zIndex from './styles/zIndex'
47-
import { Themer, ThemerContext } from './styles/themer/index'
47+
import { Themer, ThemerContext, ThemerProvider } from './styles/themer/index'
4848
import withTheme, { WithThemeInjectedProps } from './styles/themer/withTheme'
4949
import Slide from './components/Transitions/Slide'
5050
import Grow from './components/Transitions/Grow'
@@ -103,6 +103,7 @@ export {
103103
// theming
104104
Themer,
105105
ThemerContext,
106+
ThemerProvider,
106107
withTheme,
107108
WithThemeInjectedProps,
108109
themePropTypes,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Context } from 'react'
2+
import { Themer } from './Themer'
3+
import * as React from 'react'
4+
5+
export interface ThemerProviderProps {
6+
children?: React.ReactNode
7+
themer: Themer
8+
}
9+
10+
export declare const ThemerProvider: React.ComponentType<ThemerProviderProps>

src/styles/themer/ThemerProvider.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ export class ThemerProvider extends React.Component {
3131

3232
render() {
3333
const { themer, children } = this.props
34-
const { tick } = this.state
35-
return <ThemerContext.Provider value={{ themer, tick }}>{children}</ThemerContext.Provider>
34+
// this creates a new reference every time render gets called
35+
const themerContext = { themer }
36+
return <ThemerContext.Provider value={themerContext}>{children}</ThemerContext.Provider>
3637
}
3738
}
3839

src/styles/themer/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { Themer } from './Themer'
22
export { ThemerContext } from './ThemerContext'
3+
export { ThemerProvider } from './ThemerProvider'

0 commit comments

Comments
 (0)