-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrite themer to use a react context #450
base: master
Are you sure you want to change the base?
Conversation
src/styles/themer/ThemerProvider.js
Outdated
render() { | ||
const { themer, children } = this.props | ||
const { tick } = this.state | ||
return <ThemerContext.Provider value={{ themer, tick }}>{children}</ThemerContext.Provider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically you don't need to pass tick
here, because you're already creating a new object every time this render()
method runs, which will happen after you setState
. Context doesn't do deep comparisons to determine if the value has changed, it's referential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM tho I think Nathan is correct if you want to remove the tick trick (ha!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
published |
This is a breaking change
consumers need to hook up the
ThemeProvider
to their ownThemer
class reference to get custom themes.the default theme still works out of the box with no change