Skip to content

Commit

Permalink
remove tick and add types for ThemeProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
NinjaBanjo committed Mar 26, 2021
1 parent cf04e13 commit 92c5dd1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import MenuItem from './components/Menus/MenuItem'
import MenuDivider from './components/Menus/MenuDivider'
import DropdownMenu from './components/Menus/DropdownMenu'
import zIndex from './styles/zIndex'
import { Themer, ThemerContext } from './styles/themer/index'
import { Themer, ThemerContext, ThemerProvider } from './styles/themer/index'
import withTheme, { WithThemeInjectedProps } from './styles/themer/withTheme'
import Slide from './components/Transitions/Slide'
import Grow from './components/Transitions/Grow'
Expand Down Expand Up @@ -103,6 +103,7 @@ export {
// theming
Themer,
ThemerContext,
ThemerProvider,
withTheme,
WithThemeInjectedProps,
themePropTypes,
Expand Down
10 changes: 10 additions & 0 deletions src/styles/themer/ThemerProvider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Context } from 'react'
import { Themer } from './Themer'
import * as React from 'react'

export interface ThemerProviderProps {
children?: React.ReactNode
themer: Themer
}

export declare const ThemerProvider: React.ComponentType<ThemerProviderProps>
5 changes: 3 additions & 2 deletions src/styles/themer/ThemerProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export class ThemerProvider extends React.Component {

render() {
const { themer, children } = this.props
const { tick } = this.state
return <ThemerContext.Provider value={{ themer, tick }}>{children}</ThemerContext.Provider>
// this creates a new reference every time render gets called
const themerContext = { themer }
return <ThemerContext.Provider value={themerContext}>{children}</ThemerContext.Provider>
}
}

Expand Down
1 change: 1 addition & 0 deletions src/styles/themer/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { Themer } from './Themer'
export { ThemerContext } from './ThemerContext'
export { ThemerProvider } from './ThemerProvider'

0 comments on commit 92c5dd1

Please sign in to comment.