Change BG using React State

Hey everyone, So I have a page with different radio buttons bg1, bg2,....bg10 That page is in a different route For eg: /themes/ Now whenever the user changes the radio button I want to change the background image of the whole document with user type How can I do this in React?
3 Replies
Bumble
Bumble•8mo ago
You should store the state in a global element like the dom or global state so it does not depend on the path.
Banidja
Banidja•8mo ago
Yep, you can use Context API or some other library, like zustand
Mike
Mike•8mo ago
+1 for raising the state If the background will change for only one specific route (along with that route's subroutes), you may want to apply that change with a layout file and move the route to a route group 😄 https://nextjs.org/docs/app/building-your-application/routing/route-groups
Routing: Route Groups | Next.js
Route Groups can be used to partition your Next.js application into different sections.
Want results from more Discord servers?
Add your server