Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NinjaBanjo
Copy link
Member

This is a breaking change

consumers need to hook up the ThemeProvider to their own Themer class reference to get custom themes.

the default theme still works out of the box with no change

render() {
const { themer, children } = this.props
const { tick } = this.state
return <ThemerContext.Provider value={{ themer, tick }}>{children}</ThemerContext.Provider>
Copy link
Collaborator

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.

dmatteo
dmatteo previously approved these changes Mar 25, 2021
Copy link

@dmatteo dmatteo left a 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!)

Copy link

@dmatteo dmatteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@NinjaBanjo
Copy link
Member Author

published 0.0.157-prerelease.1 for now because of blocking pr, and this is p0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants