-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript is not recognize the React.FC children in as props #61015
Comments
This is working correctly. The argument You need to adjust your type accordingly. It's commonly done: |
issue: when we assign FC to a component in react which means the react function component and react function component have their own children inside of the function and no need to write children again in the props or interfaces. but I'm getting an error from the typescript.
I know this work I try to use the function component (FC) and work fine but I have a typescript error, how can I correct the type error. |
@mohamad-es try type TDropdown = {
summary: string;
dropdownRef: RefObject<HTMLDetailsElement>;
className?: string;
};
const Dropdown: FC<PropsWithChildren<TDropdown>> = ({ summary, dropdownRef, className, children }) => {
// ...
} Note that |
🔎 Search Terms
"React.FC children", "not recognize children", "error for children in use of React.FC"
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
React.FC has its own children property in props and doesn't need to add children in the type definition. but I'm getting an error about it.
error: Property 'children' does not exist on type 'Props'.ts(2339)
🙂 Expected behavior
the error must be gone and accept this behavior
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: