Skip to content
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

Children prop type missing in HeadProvider #140

Closed
itaditya opened this issue Jun 2, 2022 · 7 comments · Fixed by #146
Closed

Children prop type missing in HeadProvider #140

itaditya opened this issue Jun 2, 2022 · 7 comments · Fixed by #146

Comments

@itaditya
Copy link

itaditya commented Jun 2, 2022

Getting this TS error

image

Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & { headTags?: ReactElement<unknown, string | JSXElementConstructor>[] | undefined; }'.

Fix for this-

since HeadProvider uses children prop, it's typescript definition should include children: ReactNode

@tizmagik
Copy link
Owner

tizmagik commented Jun 2, 2022

Can you create a reproduction on Codesandbox or something? I'm not able to repro... https://codesandbox.io/s/modest-matsumoto-try7wg?file=/src/App.tsx

@itaditya
Copy link
Author

itaditya commented Jun 2, 2022

here's a simple Vite based app. Let me know if this will do otherwise I'll make one on Stackblitz.

https://github.com/itaditya/friendly-ui/blob/main/packages/react/src/App.tsx

@itaditya
Copy link
Author

itaditya commented Jun 2, 2022

I noticed the types in your CSB are of React 17 whereas mine are of React 18

"devDependencies": {
"@types/react": "17.0.20",
"@types/react-dom": "17.0.9",
"typescript": "4.4.2"
},

"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@vitejs/plugin-react": "^1.3.0",
"typescript": "^4.6.3",
"vite": "^2.9.9"
}

@tizmagik
Copy link
Owner

tizmagik commented Jun 2, 2022

Ah, yea I haven't tested react-head against React 18. It's possible it needs some updates. Feel free to open a PR to address any type issues with React 18.

@abhishiv
Copy link

abhishiv commented Jun 6, 2022

Can confirm I face the same issue with react18.

    const H = HeadProvider as any;
    const element = (
      <H headTags={headTags}>
      </H>
    );

@marhaupe
Copy link
Contributor

This MR should fix this issue: #146

tizmagik pushed a commit that referenced this issue Aug 10, 2022
This issue breaks apps with React 18. Fixes #140

Co-authored-by: Marcel Haupenthal <marcel.haupenthal@hornbach.com>
@tizmagik
Copy link
Owner

Fixed in v3.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants