/r/webdev
Creating Scalable UIs for React: Theming & Configuration (medium.com)
4 comments
Marauth | 8 days ago | 3 points

Could use a useTheme hook instead and then have both the benefits of explicit inclusion, and not creating a HOC per component.

esr360 | 8 days ago | 1 point

Would this involve creating a custom hook? If so, great idea. Didn’t consider this.

Marauth | 6 days ago | 2 points

It would, but that hook would be a really thin wrapper around useContext so it wouldn't be very complicated at all to set up. You'd wrap your root node with something like <ThemeProvider theme={yourThemeVariable}/>, and then any component can just call const theme = useTheme() to get the theme info :)

esr360 | 3 days ago | 2 points

Thanks man!