File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
packages/devextreme-cli/src/templates/nextjs/application/src Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 11'use client'
22
3- import { usePathname } from 'next/navigation' ;
43import LoadPanel from 'devextreme-react/load-panel' ;
5- import { AuthProvider , useAuth } from '@/contexts/auth' ;
6- import { ThemeContext , useThemeContext } from "@/theme" ;
4+ import { AuthProvider , useAuth } from '@/contexts/auth' ;
5+ import { ThemeProvider } from "@/theme" ;
76
87function Page ( { children } ) {
98 const { loading } = useAuth ( ) ;
@@ -16,21 +15,18 @@ function Page({ children }) {
1615}
1716
1817export default function RootLayout ( { children } ) {
19- const themeContext = useThemeContext ( ) ;
20- const pathname = usePathname ( ) ;
21-
2218 return (
2319 < html lang = "en" >
2420 < title > NextJs Dx App</ title >
2521 < body className = "dx-viewport" >
26- < ThemeContext . Provider value = { themeContext } >
22+ < ThemeProvider >
2723 < AuthProvider >
2824 < div className = 'app' >
29- < Page key = { pathname } > { children } </ Page >
25+ < Page > { children } </ Page >
3026 </ div >
3127 </ AuthProvider >
32- </ ThemeContext . Provider >
33- </ body >
28+ </ ThemeProvider >
29+ </ body >
3430 </ html >
3531 ) ;
3632}
Original file line number Diff line number Diff line change @@ -54,3 +54,13 @@ export function useThemeContext() {
5454}
5555
5656export const ThemeContext = React . createContext < %= #isTypeScript% > < ReturnType < typeof useThemeContext > | null > < %= / i s T y p e S c r i p t % > ( n u l l ) ;
57+
58+ export const ThemeProvider = ( { children } < %= #isTypeScript% > : React . PropsWithChildren < %= / i s T y p e S c r i p t % > ) = > {
59+ const themeContext = useThemeContext ( ) ;
60+
61+ return (
62+ < ThemeContext . Provider value = { themeContext } >
63+ { children }
64+ </ ThemeContext . Provider >
65+ ) ;
66+ } ;
You can’t perform that action at this time.
0 commit comments