Currently, I am faced with a challenge involving two theme files, theme.js
and theme-dark.js
, within the context of a complex React-based website. Despite having already set up the site, I am struggling to find a way to allow users to seamlessly switch between these two themes using a switcher integrated into the website.
The following snippet showcases how my index.js
render function is structured:
const rootElement = document.getElementById('root')
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
rootElement
)
Moreover, this excerpt illustrates the relevant code present in the App.tsx
file:
<ThemeProvider theme={theme}>
<CssBaseline />
<SnackbarProvider
.....
</SnackbarProvider>
</ThemeProvider>
Within the App.tsx
file, the above code is nested within custom Context provider components responsible for loading the initial components of the site.
Despite providing the existing code snippets above, I have hit a roadblock when attempting to incorporate a functionality allowing the user to toggle between the theme.js
and theme-dark.js
themes. Any guidance or assistance that can be provided would be profoundly appreciated. Unfortunately, due to security protocols at my company, I am unable to share additional code. However, it appears that the main obstacle lies in the conflict arising when introducing a custom theme provider alongside the <Provider>
element in index.js
.