Closed eunjijeon11 closed 6 months ago
@eunjijeon11 after digging a bit, I found that next-themes team has already made children
optional in this commit because children
is not passed in explicitly and they wish to ensure the types are compatible with the previous version. You can see the code in main branch and they haven't released yet. v0.3.0 was out on 13 Mar and the above commit was made on 20 Mar.
Therefore, I don't think it's a good idea to bump next-themes
to v.0.3.0
in NextUI since it is a breaking change and that prop would become optional after their next release. I'd suggest you to use our supported version v0.2.1
first and wait for their next release.
Closing - as it's not planned.
@wingkwong Ok, but when I started a project with nextui init my-nextui-app
, package.json had the next-themes
version ^0.3.0.
So I think somebody else can have the same problem. Thank you for the fast reply.
I'll have a look and get back to you later.
@eunjijeon11 I tried to init new projects with app and page template using CLI. It was using ^0.2.1
for both project. Are you using the latest CLI?
@wingkwong I'm using next-ui CLI v0.3.1
.
I checked again and the team member uploaded the version, so there was a problem. I don't think there's anything wrong with nextui.
@eunjijeon11 Thanks for the confirmation.
I've encountered a TypeScript error that says: Property 'children' is missing in type '{ attribute: string; defaultTheme: string; }' but required in type 'ThemeProviderProps'.
To fix this, ensure that the themeProps
object includes the children
property when it's passed to the NextThemesProvider
. To exclude the children
property from the themeProps
type, you can use Omit<ThemeProviderProps, 'children'>
.
"use client";
import * as React from "react";
import { NextUIProvider } from "@nextui-org/system";
import { useRouter } from "next/navigation";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { ThemeProviderProps } from "next-themes/dist/types";
export interface ProvidersProps {
children: React.ReactNode;
themeProps?: Omit<ThemeProviderProps, "children">;
}
export function Providers({ children, themeProps }: ProvidersProps) {
const router = useRouter();
return (
<NextUIProvider navigate={router.push}>
<NextThemesProvider {...themeProps}>{children}</NextThemesProvider>
</NextUIProvider>
);
}
NextUI Version
2.4.0
Describe the bug
I got an error like this. It occured in the
app/layout.tsx
, which I didn't make any changes after installation.And the problem was prop 'children' in type ThemeProviderProps
When I downgraded the next-themes version from 0.3.0 to 0.2.1, it worked well. I think Next ui should be updated also.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Expected behavior
This error didn't make an effect when I run
npm run dev
. It occured only when I build the project withnpm run build
. I expected it to be build successfully.Screenshots or Videos
No response
Operating System Version
Windows
Browser
Chrome