epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.32k stars 355 forks source link

chore: move theme switch to full stack component #737

Closed lsbyerley closed 3 months ago

lsbyerley commented 3 months ago

If merged, this PR moves the theme switch component out of root and into it's own full stack component.

I have made this change in my own codebase after coming across https://www.epicweb.dev/full-stack-components and in an effort to reduce bloat in the root file. If this change is not wanted, feel free to close :)

Test Plan

Functionality and display of the theme switch component should not change.

Checklist

Screenshots

fredericrous commented 3 months ago

So basically, by exporting a component from a route (here resources+), I get encapsulated loader and action for free? Looks like a great solution. I wonder tho, at bundle time, will this split useTheme into its own js file? If so, because useTheme is used at app initialization time, this change could present a risk of slowing down the first render?

kentcdodds commented 3 months ago

This will not negatively impact performance :)